1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
|
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <Eris/TypeBoundRedispatch.h>
#include <Eris/Connection.h>
#include <Eris/TypeService.h>
#include <Eris/TypeInfo.h>
#include <Eris/LogStream.h>
#include <Atlas/Objects/Operation.h>
#include <sigc++/slot.h>
using namespace Atlas::Objects::Operation;
using Atlas::Objects::Root;
using Atlas::Objects::Entity::RootEntity;
using Atlas::Objects::smart_dynamic_cast;
namespace Eris
{
TypeBoundRedispatch::TypeBoundRedispatch(Connection* con,
const Root& obj,
TypeInfo* unbound) :
Redispatch(con, obj),
m_con(con)
{
m_unbound.insert(unbound);
assert(unbound->isBound() == false);
unbound->Bound.connect(sigc::mem_fun(this, &TypeBoundRedispatch::onBound));
con->getTypeService()->BadType.connect(sigc::mem_fun(this, &TypeBoundRedispatch::onBadType));
}
TypeBoundRedispatch::TypeBoundRedispatch(Connection* con,
const Root& obj,
const TypeInfoSet& unbound) :
Redispatch(con, obj),
m_con(con),
m_unbound(unbound)
{
for (TypeInfoSet::const_iterator U=m_unbound.begin(); U != m_unbound.end(); ++U) {
assert((*U)->isBound() == false);
(*U)->Bound.connect(sigc::mem_fun(this, &TypeBoundRedispatch::onBound));
}
con->getTypeService()->BadType.connect(sigc::mem_fun(this, &TypeBoundRedispatch::onBadType));
}
void TypeBoundRedispatch::onBound(TypeInfo* bound)
{
assert(m_unbound.count(bound));
m_unbound.erase(bound);
if (m_unbound.empty()) post();
}
void TypeBoundRedispatch::onBadType(TypeInfo* bad)
{
if (m_unbound.count(bad)) {
debug() << "TypeBoundRedispatch was waiting on bad type " << bad->getName();
fail();
}
}
} // of Eris namespace
|