aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2008-04-17 14:58:10 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2008-04-17 14:58:10 +0000
commit64b421cb1dbcb58845a3b752de5fd51df08d02d3 (patch)
treed178ba272b08724190e737a07477f020bbd3c608
parent5ddac55f7cdff0886560344a5391be2bde8bbf32 (diff)
downloadpaludis-64b421cb1dbcb58845a3b752de5fd51df08d02d3.tar.gz
paludis-64b421cb1dbcb58845a3b752de5fd51df08d02d3.tar.xz
More sr -> kc work
-rw-r--r--paludis/files.m42
-rw-r--r--paludis/ndbam-fwd.hh19
-rw-r--r--paludis/ndbam.cc35
-rw-r--r--paludis/ndbam.hh3
-rwxr-xr-xpaludis/ndbam.sr18
-rw-r--r--paludis/repositories/e/exndbam_repository.cc10
-rw-r--r--paludis/repositories/unpackaged/installed_repository.cc10
-rw-r--r--paludis/util/files.m42
-rw-r--r--paludis/util/keys.hh3
-rw-r--r--paludis/util/mutex-fwd.hh30
-rw-r--r--paludis/util/mutex.hh3
11 files changed, 81 insertions, 54 deletions
diff --git a/paludis/files.m4 b/paludis/files.m4
index 2168429..423d179 100644
--- a/paludis/files.m4
+++ b/paludis/files.m4
@@ -41,7 +41,7 @@ add(`merger_entry_type', `hh', `cc', `se')
add(`metadata_key', `hh', `cc', `se', `fwd')
add(`metadata_key_holder', `hh', `cc', `fwd')
add(`name', `hh', `cc', `fwd', `test', `sr', `se')
-add(`ndbam', `hh', `cc', `fwd', `sr')
+add(`ndbam', `hh', `cc', `fwd')
add(`ndbam_merger', `hh', `cc')
add(`ndbam_unmerger', `hh', `cc', `sr')
add(`override_functions', `hh', `cc')
diff --git a/paludis/ndbam-fwd.hh b/paludis/ndbam-fwd.hh
index c4a43a8..c31accc 100644
--- a/paludis/ndbam-fwd.hh
+++ b/paludis/ndbam-fwd.hh
@@ -21,11 +21,28 @@
#define PALUDIS_GUARD_PALUDIS_REPOSITORIES_UNPACKAGED_NDBAM_FWD_HH 1
#include <paludis/util/sequence-fwd.hh>
+#include <paludis/util/kc-fwd.hh>
+#include <paludis/util/keys.hh>
+#include <paludis/util/fs_entry-fwd.hh>
+#include <paludis/util/mutex-fwd.hh>
+#include <paludis/name-fwd.hh>
+#include <paludis/version_spec-fwd.hh>
+#include <paludis/package_id-fwd.hh>
namespace paludis
{
class NDBAM;
- class NDBAMEntry;
+
+ typedef kc::KeyedClass<
+ kc::Field<k::name, QualifiedPackageName>,
+ kc::Field<k::version, VersionSpec>,
+ kc::Field<k::slot, SlotName>,
+ kc::Field<k::fs_location, FSEntry>,
+ kc::Field<k::magic, std::string>,
+ kc::Field<k::package_id, tr1::shared_ptr<PackageID> >,
+ kc::Field<k::mutex, tr1::shared_ptr<Mutex> >
+ > NDBAMEntry;
+
typedef Sequence<tr1::shared_ptr<NDBAMEntry> > NDBAMEntrySequence;
}
diff --git a/paludis/ndbam.cc b/paludis/ndbam.cc
index ccde96d..f801b24 100644
--- a/paludis/ndbam.cc
+++ b/paludis/ndbam.cc
@@ -28,6 +28,7 @@
#include <paludis/util/make_shared_ptr.hh>
#include <paludis/util/tr1_functional.hh>
#include <paludis/util/config_file.hh>
+#include <paludis/util/kc.hh>
#include <paludis/ndbam.hh>
#include <paludis/hashed_containers.hh>
#include <paludis/package_id.hh>
@@ -40,8 +41,6 @@
using namespace paludis;
-#include <paludis/ndbam-sr.cc>
-
template class Sequence<tr1::shared_ptr<NDBAMEntry> >;
namespace
@@ -269,11 +268,13 @@ NDBAM::has_package_named(const QualifiedPackageName & q)
namespace
{
- template <typename T_>
- T_ * desptr(const tr1::shared_ptr<T_> & p)
+ struct NDBAMEntryVersionComparator
{
- return p.get();
- }
+ bool operator() (const tr1::shared_ptr<const NDBAMEntry> & a, const tr1::shared_ptr<const NDBAMEntry> & b) const
+ {
+ return (*a)[k::version()] < (*b)[k::version()];
+ }
+ };
}
tr1::shared_ptr<NDBAMEntrySequence>
@@ -322,14 +323,14 @@ NDBAM::entries(const QualifiedPackageName & q)
VersionSpec v(tokens[0]);
SlotName s(tokens[1]);
std::string m(tokens[2]);
- pc.entries->push_back(make_shared_ptr(new NDBAMEntry(NDBAMEntry::create()
- .name(q)
- .version(v)
- .slot(s)
- .fs_location(d->realpath())
- .package_id(tr1::shared_ptr<PackageID>())
- .magic(m)
- .mutex(make_shared_ptr(new Mutex)))));
+ pc.entries->push_back(make_shared_ptr(new NDBAMEntry(NDBAMEntry::named_create()
+ (k::name(), q)
+ (k::version(), v)
+ (k::slot(), s)
+ (k::fs_location(), d->realpath())
+ (k::package_id(), tr1::shared_ptr<PackageID>())
+ (k::magic(), m)
+ (k::mutex(), make_shared_ptr(new Mutex)))));
}
catch (const InternalError &)
{
@@ -343,11 +344,7 @@ NDBAM::entries(const QualifiedPackageName & q)
}
using namespace tr1::placeholders;
- pc.entries->sort(
- tr1::bind(std::less<VersionSpec>(),
- tr1::bind<VersionSpec>(tr1::mem_fn(&NDBAMEntry::version), tr1::bind(&desptr<const NDBAMEntry>, _1)),
- tr1::bind<VersionSpec>(tr1::mem_fn(&NDBAMEntry::version), tr1::bind(&desptr<const NDBAMEntry>, _2))
- ));
+ pc.entries->sort(NDBAMEntryVersionComparator());
}
return pc.entries;
diff --git a/paludis/ndbam.hh b/paludis/ndbam.hh
index 010958c..775e927 100644
--- a/paludis/ndbam.hh
+++ b/paludis/ndbam.hh
@@ -34,9 +34,6 @@
namespace paludis
{
-
-#include <paludis/ndbam-sr.hh>
-
/**
* NDBAM provides a partial implementation of a Repository for installed packages using
* a Paludis-defined on-disk format. It is used by unpackaged repositories and exndbam,
diff --git a/paludis/ndbam.sr b/paludis/ndbam.sr
deleted file mode 100755
index 2e0ec03..0000000
--- a/paludis/ndbam.sr
+++ /dev/null
@@ -1,18 +0,0 @@
-#!/bin/bash
-# vim: set sw=4 sts=4 et :
-
-make_class_NDBAMEntry()
-{
- visible
-
- key name QualifiedPackageName
- key version VersionSpec
- key slot SlotName
- key fs_location FSEntry
- key magic "std::string"
- key package_id "tr1::shared_ptr<PackageID>"
- key mutex "tr1::shared_ptr<Mutex>"
-
- allow_named_args
-}
-
diff --git a/paludis/repositories/e/exndbam_repository.cc b/paludis/repositories/e/exndbam_repository.cc
index fa29681..628152d 100644
--- a/paludis/repositories/e/exndbam_repository.cc
+++ b/paludis/repositories/e/exndbam_repository.cc
@@ -200,11 +200,11 @@ ExndbamRepository::package_ids(const QualifiedPackageName & q) const
for (IndirectIterator<NDBAMEntrySequence::ConstIterator> e(entries->begin()), e_end(entries->end()) ;
e != e_end ; ++e)
{
- Lock l(*e->mutex);
- if (! e->package_id)
- e->package_id.reset(new ExndbamID(e->name, e->version, _imp->params.environment,
- shared_from_this(), e->fs_location, &_imp->ndbam));
- result->push_back(e->package_id);
+ Lock l(*(*e)[k::mutex()]);
+ if (! (*e)[k::package_id()])
+ (*e)[k::package_id()].reset(new ExndbamID((*e)[k::name()], (*e)[k::version()], _imp->params.environment,
+ shared_from_this(), (*e)[k::fs_location()], &_imp->ndbam));
+ result->push_back((*e)[k::package_id()]);
}
return result;
diff --git a/paludis/repositories/unpackaged/installed_repository.cc b/paludis/repositories/unpackaged/installed_repository.cc
index 77a2a67..6777c12 100644
--- a/paludis/repositories/unpackaged/installed_repository.cc
+++ b/paludis/repositories/unpackaged/installed_repository.cc
@@ -125,11 +125,11 @@ InstalledUnpackagedRepository::package_ids(const QualifiedPackageName & q) const
for (IndirectIterator<NDBAMEntrySequence::ConstIterator> e(entries->begin()), e_end(entries->end()) ;
e != e_end ; ++e)
{
- Lock l(*e->mutex);
- if (! e->package_id)
- e->package_id.reset(new InstalledUnpackagedID(_imp->params.environment, e->name, e->version,
- e->slot, name(), e->fs_location, e->magic, installed_root_key()->value(), &_imp->ndbam));
- result->push_back(e->package_id);
+ Lock l(*(*e)[k::mutex()]);
+ if (! (*e)[k::package_id()])
+ (*e)[k::package_id()].reset(new InstalledUnpackagedID(_imp->params.environment, (*e)[k::name()], (*e)[k::version()],
+ (*e)[k::slot()], name(), (*e)[k::fs_location()], (*e)[k::magic()], installed_root_key()->value(), &_imp->ndbam));
+ result->push_back((*e)[k::package_id()]);
}
return result;
diff --git a/paludis/util/files.m4 b/paludis/util/files.m4
index ac62bbc..20fcc54 100644
--- a/paludis/util/files.m4
+++ b/paludis/util/files.m4
@@ -37,7 +37,7 @@ add(`make_shared_ptr', `hh', `fwd')
add(`map', `hh', `fwd', `impl', `cc')
add(`member_iterator', `hh', `fwd', `impl', `test')
add(`md5', `hh', `cc', `test')
-add(`mutex', `hh', `cc', `test')
+add(`mutex', `hh', `cc', `fwd', `test')
add(`no_type', `hh')
add(`operators', `hh')
add(`options', `hh', `fwd', `cc', `test')
diff --git a/paludis/util/keys.hh b/paludis/util/keys.hh
index 6df11d4..1373409 100644
--- a/paludis/util/keys.hh
+++ b/paludis/util/keys.hh
@@ -159,6 +159,9 @@ namespace paludis
typedef kc::Key<130> build_dependencies;
typedef kc::Key<131> run_dependencies;
typedef kc::Key<132> description;
+ typedef kc::Key<133> fs_location;
+ typedef kc::Key<134> magic;
+ typedef kc::Key<135> mutex;
}
}
diff --git a/paludis/util/mutex-fwd.hh b/paludis/util/mutex-fwd.hh
new file mode 100644
index 0000000..ca9c22a
--- /dev/null
+++ b/paludis/util/mutex-fwd.hh
@@ -0,0 +1,30 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2008 Ciaran McCreesh
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef PALUDIS_GUARD_PALUDIS_UTIL_MUTEX_FWD_HH
+#define PALUDIS_GUARD_PALUDIS_UTIL_MUTEX_FWD_HH 1
+
+namespace paludis
+{
+ class Mutex;
+ class Lock;
+ class TryLock;
+}
+
+#endif
diff --git a/paludis/util/mutex.hh b/paludis/util/mutex.hh
index 410894b..38586a6 100644
--- a/paludis/util/mutex.hh
+++ b/paludis/util/mutex.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2007 Ciaran McCreesh
+ * Copyright (c) 2007, 2008 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -20,6 +20,7 @@
#ifndef PALUDIS_GUARD_PALUDIS_UTIL_MUTEX_HH
#define PALUDIS_GUARD_PALUDIS_UTIL_MUTEX_HH 1
+#include <paludis/util/mutex-fwd.hh>
#include <paludis/util/attributes.hh>
#ifdef PALUDIS_ENABLE_THREADS