summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2015-01-11 16:49:27 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2015-01-11 16:49:27 +0000
commit646cbc2f3947a2f1b0496490854adaf0ae82c56e (patch)
tree97aa1c2ace8c96fdb192f01fded2b25d4a864193
parentFix the compat interface and add covering test (diff)
downloadslicer-646cbc2f3947a2f1b0496490854adaf0ae82c56e.tar.bz2
slicer-646cbc2f3947a2f1b0496490854adaf0ae82c56e.tar.xz
slicer-646cbc2f3947a2f1b0496490854adaf0ae82c56e.zip
Rework ChildRefs to avoid linking/loading/unloading problems laterslicer-1.0.0
-rw-r--r--slicer/slicer/modelParts.h33
-rw-r--r--slicer/slicer/slicer.cpp20
2 files changed, 23 insertions, 30 deletions
diff --git a/slicer/slicer/modelParts.h b/slicer/slicer/modelParts.h
index deb32e1..a28de0c 100644
--- a/slicer/slicer/modelParts.h
+++ b/slicer/slicer/modelParts.h
@@ -143,9 +143,9 @@ namespace Slicer {
virtual const Metadata & ChildMetaData() const = 0;
};
typedef IceUtil::Handle<ChildRef> ChildRefPtr;
- class DirectChildRef : public ChildRef {
+ class ImplicitChildRef : public ChildRef {
public:
- DirectChildRef(ModelPartPtr);
+ ImplicitChildRef(ModelPartPtr);
ModelPartPtr Child() const;
const Metadata & ChildMetaData() const;
@@ -153,19 +153,16 @@ namespace Slicer {
private:
ModelPartPtr mpp;
};
- class FunctionChildRef : public ChildRef {
+ class MemberChildRef : public ChildRef {
public:
- typedef boost::function<ModelPartPtr()> ModelPartFunc;
- typedef boost::function<const Metadata &()> MetadataFunc;
-
- FunctionChildRef(const ModelPartFunc &, const MetadataFunc &);
+ MemberChildRef(ModelPartPtr, const Metadata &);
ModelPartPtr Child() const;
const Metadata & ChildMetaData() const;
private:
- ModelPartFunc mpf;
- MetadataFunc mdf;
+ ModelPartPtr mpp;
+ const Metadata & mdr;
};
class ModelPart : public IceUtil::Shared {
@@ -377,9 +374,7 @@ namespace Slicer {
{
for (const auto & h : hooks) {
if (!flt || flt(h)) {
- return new FunctionChildRef(
- boost::bind(&HookBase::Get, h, GetModel()),
- boost::bind(&HookBase::GetMetadata, h));
+ return new MemberChildRef(h->Get(GetModel()), h->GetMetadata());
}
}
return NULL;
@@ -388,9 +383,7 @@ namespace Slicer {
{
for (const auto & h : hooks) {
if (h->PartName() == name && (!flt || flt(h))) {
- return new FunctionChildRef(
- boost::bind(&HookBase::Get, h, GetModel()),
- boost::bind(&HookBase::GetMetadata, h));
+ return new MemberChildRef(h->Get(GetModel()), h->GetMetadata());
}
}
return NULL;
@@ -507,7 +500,7 @@ namespace Slicer {
virtual ChildRefPtr GetAnonChildRef(const HookFilter &) override
{
mp->Create();
- return new DirectChildRef(mp);
+ return new ImplicitChildRef(mp);
}
virtual ChildRefPtr GetChildRef(const std::string & name, const HookFilter &) override
@@ -516,7 +509,7 @@ namespace Slicer {
throw IncorrectElementName(name);
}
mp->Create();
- return new DirectChildRef(mp);
+ return new ImplicitChildRef(mp);
}
virtual void OnEachChild(const ChildHandler & ch) override
@@ -568,7 +561,7 @@ namespace Slicer {
ChildRefPtr GetAnonChildRef(const HookFilter &) override
{
sequence.push_back(typename element_type::value_type());
- return new DirectChildRef(ModelPartFor(sequence.back()));
+ return new ImplicitChildRef(ModelPartFor(sequence.back()));
}
ChildRefPtr GetChildRef(const std::string &, const HookFilter &) override;
@@ -649,7 +642,7 @@ namespace Slicer {
ChildRefPtr GetAnonChildRef(const HookFilter &) override
{
- return new DirectChildRef(new ModelPartForDictionaryElementInserter<T>(dictionary));
+ return new ImplicitChildRef(new ModelPartForDictionaryElementInserter<T>(dictionary));
}
ChildRefPtr GetChildRef(const std::string & name, const HookFilter &) override
@@ -657,7 +650,7 @@ namespace Slicer {
if (name != pairName) {
throw IncorrectElementName(name);
}
- return new DirectChildRef(new ModelPartForDictionaryElementInserter<T>(dictionary));
+ return new ImplicitChildRef(new ModelPartForDictionaryElementInserter<T>(dictionary));
}
virtual bool HasValue() const override { return true; }
diff --git a/slicer/slicer/slicer.cpp b/slicer/slicer/slicer.cpp
index 3af8bea..a060956 100644
--- a/slicer/slicer/slicer.cpp
+++ b/slicer/slicer/slicer.cpp
@@ -15,37 +15,37 @@ namespace Slicer {
MODELPARTFOR(Ice::Long, ModelPartForSimple);
#undef MODELPARTFOR
- Slicer::FunctionChildRef::FunctionChildRef(const Slicer::FunctionChildRef::ModelPartFunc & mp, const Slicer::FunctionChildRef::MetadataFunc & md) :
- mpf(mp),
- mdf(md)
+ Slicer::MemberChildRef::MemberChildRef(Slicer::ModelPartPtr mp, const Slicer::Metadata & md) :
+ mpp(mp),
+ mdr(md)
{
}
ModelPartPtr
- Slicer::FunctionChildRef::Child() const
+ Slicer::MemberChildRef::Child() const
{
- return mpf();
+ return mpp;
}
const Metadata &
- Slicer::FunctionChildRef::ChildMetaData() const
+ Slicer::MemberChildRef::ChildMetaData() const
{
- return mdf();
+ return mdr;
}
- Slicer::DirectChildRef::DirectChildRef(ModelPartPtr m) :
+ Slicer::ImplicitChildRef::ImplicitChildRef(ModelPartPtr m) :
mpp(m)
{
}
ModelPartPtr
- Slicer::DirectChildRef::Child() const
+ Slicer::ImplicitChildRef::Child() const
{
return mpp;
}
const Metadata &
- Slicer::DirectChildRef::ChildMetaData() const
+ Slicer::ImplicitChildRef::ChildMetaData() const
{
return emptyMetadata;
}