#include <bbtkConnection.h>
Public Types | |
typedef Connection | Self |
typedef boost::shared_ptr< Self > | Pointer |
typedef boost::weak_ptr< Self > | WeakPointer |
Public Member Functions | |
std::string | GetObjectName () const |
std::string | GetObjectInfo () const |
size_t | GetObjectSize () const |
size_t | GetObjectInternalSize () const |
size_t | GetObjectRecursiveSize () const |
void | RecursiveExecute () |
Dtor. | |
void | OnOutputChange (BlackBoxPointer, const std::string &, IOStatus) |
Change callback. | |
std::string | GetFullName () const |
BlackBoxPointer | GetOriginalBlackBoxFrom () const |
Returns the original initial black box of the connection. | |
BlackBoxPointer | GetOriginalBlackBoxTo () const |
Returns the origianl final black box of the connection. | |
const std::string & | GetOriginalBlackBoxFromOutput () const |
Returns the original output of the initial black box of the connection. | |
const std::string & | GetOriginalBlackBoxToInput () const |
Returns the original input of the final black box of the connection. | |
BlackBoxPointer | GetBlackBoxFrom () const |
Returns the initial black box of the connection. | |
BlackBoxPointer | GetBlackBoxTo () const |
Returns the final black box of the connection. | |
const std::string & | GetBlackBoxFromOutput () const |
Returns the output of the initial black box of the connection. | |
const std::string & | GetBlackBoxToInput () const |
Returns the input of the final black box of the connection. | |
void | SetBlackBoxFrom (BlackBoxPointer b) |
Sets the initial black box of the connection. | |
void | SetBlackBoxTo (BlackBoxPointer b) |
Sets the final black box of the connection. | |
void | SetBlackBoxFromOutput (const std::string &o) |
Sets the output of the initial black box of the connection. | |
void | SetBlackBoxToInput (const std::string &o) |
Sets the input of the final black box of the connection. | |
void | Check () const |
Checks that the connection is ok (throws error if not). | |
void | TransferData () |
long | GetUseCount () |
Static Public Member Functions | |
static Pointer | New (BlackBoxPointer from, const std::string &output, BlackBoxPointer to, const std::string &input, const FactoryPointer f) |
static Pointer | New (BlackBoxPointer from, const std::string &output, BlackBoxPointer to, const std::string &input) |
static void | InsertInObjectList (Pointer) |
static void | RemoveFromObjectList (WeakPointer) |
static void | InsertInPackageList (Pointer) |
static void | ReleasePackages () |
static void | PrintObjectListInfo (const std::string &name) |
static void | PrintObjectInfo (const Pointer &o) |
static long | GetObjectsCount () |
Protected Types | |
typedef Object | Superclass |
Protected Member Functions | |
Connection () | |
Connection (const Connection &) | |
~Connection () | |
Dtor. | |
void | LockThis () |
void | UnLockThis () |
template<class U > | |
boost::shared_ptr< U > | GetThisPointer () const |
Static Protected Member Functions | |
template<class U > | |
static boost::shared_ptr< U > | MakePointer (U *s, bool lock=false) |
template<class U , class D > | |
static boost::shared_ptr< U > | MakePointer (U *s, const D &del, bool lock=false) |
Protected Attributes | |
BlackBoxPointer | mFrom |
Black box origin of the connection. | |
BlackBoxWeakPointer | mOriginalFrom |
std::string | mOutput |
Output of mFrom which is connected. | |
std::string | mOriginalOutput |
BlackBoxPointer | mTo |
Output connector of mFrom which is connected. | |
BlackBoxWeakPointer | mOriginalTo |
std::string | mInput |
Input of mTo which is connected. | |
std::string | mOriginalInput |
BlackBoxPointer | mAdaptor |
Input connector of mTo which is connected. | |
const FactoryWeakPointer | mFactory |
The factory used to create adaptors. | |
bool | mFromAny |
Is the connection input type is any<thing> ? | |
bool | mToAny |
Is the connection output type is any<thing> ? | |
bool | mDoDynamicCast |
Have to do dynamic_cast ? | |
Private Member Functions | |
Connection (BlackBoxPointer from, const std::string &output, BlackBoxPointer to, const std::string &input, const FactoryPointer f) | |
Ctor. | |
Connection (BlackBoxPointer from, const std::string &output, BlackBoxPointer to, const std::string &input) | |
Ctor. | |
Friends | |
struct | Object::Deleter |
Definition at line 71 of file bbtkConnection.h.
typedef boost::shared_ptr<Self> bbtk::Connection::Pointer |
typedef Connection bbtk::Connection::Self |
Definition at line 73 of file bbtkConnection.h.
typedef Object bbtk::Connection::Superclass [protected] |
Definition at line 73 of file bbtkConnection.h.
typedef boost::weak_ptr<Self> bbtk::Connection::WeakPointer |
bbtk::Connection::Connection | ( | ) | [protected] |
bbtk::Connection::Connection | ( | const Connection & | ) | [protected] |
bbtk::Connection::~Connection | ( | ) | [protected] |
Dtor.
Definition at line 309 of file bbtkConnection.cxx.
References bbtkCDebugMessage, bbtkInternalError, mAdaptor, mFrom, mInput, mOutput, and mTo.
00310 { 00311 bbtkCDebugMessage("object",4, 00312 "==> ~Connection()" 00313 <<std::endl); 00314 00315 if (mAdaptor) mAdaptor.reset(); 00316 if (mFrom!=0) 00317 { 00318 mFrom->bbDisconnectOutput(mOutput,this); 00319 // GetThisPointer<Connection>()); 00320 mFrom.reset(); 00321 } 00322 else 00323 { 00324 bbtkInternalError("~Connection() : invalid initial box pointer"); 00325 } 00326 if (mTo!=0) 00327 { 00328 mTo->bbDisconnectInput(mInput,this);// GetThisPointer<Connection>()); 00329 mTo.reset(); 00330 } 00331 else 00332 { 00333 bbtkInternalError("~Connection() : invalid final box pointer"); 00334 } 00335 00336 00337 bbtkCDebugMessage("object",4, 00338 "<== ~Connection()" 00339 <<std::endl); 00340 }
bbtk::Connection::Connection | ( | BlackBoxPointer | from, | |
const std::string & | output, | |||
BlackBoxPointer | to, | |||
const std::string & | input, | |||
const FactoryPointer | f | |||
) | [private] |
Ctor.
bbtk::Connection::Connection | ( | BlackBoxPointer | from, | |
const std::string & | output, | |||
BlackBoxPointer | to, | |||
const std::string & | input | |||
) | [private] |
Ctor.
void bbtk::Connection::Check | ( | ) | const |
Checks that the connection is ok (throws error if not).
Definition at line 553 of file bbtkConnection.cxx.
References bbtkError, bbtkMessage, GetFullName(), bbtk::i, mFrom, mInput, mOutput, and mTo.
00554 { 00555 bbtkMessage("debug",1,"** Checking Connection "<<(void*)this<<" [" 00556 <<GetFullName()<<"]" 00557 <<std::endl); 00558 if (mFrom==0) 00559 { 00560 bbtkMessage("debug",2," - From = 0"<<std::endl); 00561 } 00562 else 00563 { 00564 bbtkMessage("debug",2," - From : "<<mFrom->bbGetName()<<std::endl); 00565 if (!mFrom->bbHasOutput(mOutput)) 00566 { 00567 bbtkError("** Checking Connection "<<(void*)this 00568 <<" ["<<GetFullName()<<"] : " 00569 << mFrom->bbGetName()<<" does not have output '" 00570 <<mOutput<<"'"); 00571 } 00572 bbtkMessage("debug",2," - From : Output '"<<mOutput<<"' exists"<<std::endl); 00573 BlackBox::OutputConnectorMapType::const_iterator i 00574 = mFrom->bbGetOutputConnectorMap().find(mOutput); 00575 if (i== mFrom->bbGetOutputConnectorMap().end()) 00576 { 00577 bbtkError("** Checking Connection "<<(void*)this 00578 <<" ["<<GetFullName()<<"] : " 00579 <<mFrom->bbGetName()<<" output '" 00580 <<mOutput<<"' is not in OutputConnectorMap"); 00581 } 00582 bbtkMessage("debug",2," - From : Output '"<<mOutput 00583 <<"' is in OutputConnectorMap"<<std::endl); 00584 00585 std::vector< Connection* >::const_iterator j; 00586 /* 00587 for (j = i->second->GetConnectionVector().begin(); 00588 j != i->second->GetConnectionVector().end(); 00589 ++j) 00590 { 00591 if ((*j)==this) break; 00592 } 00593 */ 00594 j = find(i->second->GetConnectionVector().begin(), 00595 i->second->GetConnectionVector().end(), 00596 this); 00597 00598 if (j==i->second->GetConnectionVector().end()) 00599 { 00600 bbtkError("** Checking Connection "<<(void*)this 00601 <<" ["<<GetFullName()<<"] : " 00602 <<" OutputConnector '" 00603 <<mOutput<<"' of "<<mFrom->bbGetName() 00604 <<" does not point to this connection"); 00605 00606 } 00607 bbtkMessage("debug",2," - From : This connection is in OutputConnector connection vector"<<std::endl); 00608 bbtkMessage("debug",2," * Box from : Check successfull"<<std::endl); 00609 00610 } 00611 00612 if (mTo==0) 00613 { 00614 bbtkMessage("debug",2," - To = 0"<<std::endl); 00615 } 00616 else 00617 { 00618 bbtkMessage("debug",2," - To : "<<mTo->bbGetName()<<std::endl); 00619 // std::cout << mTo << std::endl; 00620 // std::cout << mTo->bbGetDescriptor() << std::endl; 00621 // std::cout << mTo->bbGetDescriptor()->GetTypeName() << std::endl; 00622 // mTo->bbGetName(); 00623 bbtkMessage("debug",2," - To : "<<mTo->bbGetName()<<std::endl); 00624 if (!mTo->bbHasInput(mInput)) 00625 { 00626 bbtkError("** Checking Connection "<<(void*)this 00627 <<" ["<<GetFullName()<<"] : " 00628 <<mTo->bbGetName()<<" does not have input '" 00629 <<mInput<<"'"); 00630 } 00631 bbtkMessage("debug",2," - To : Input '"<<mInput<<"' exists"<<std::endl); 00632 BlackBox::InputConnectorMapType::const_iterator i 00633 = mTo->bbGetInputConnectorMap().find(mInput); 00634 if (i== mTo->bbGetInputConnectorMap().end()) 00635 { 00636 bbtkError("** Checking Connection "<<(void*)this 00637 <<" ["<<GetFullName()<<"] : " 00638 <<mTo->bbGetName()<<" input '" 00639 <<mInput<<"' is not in InputConnectorMap"); 00640 } 00641 bbtkMessage("debug",2," - To : Input '"<<mInput 00642 <<"' is in InputConnectorMap"<<std::endl); 00643 00644 if (i->second->GetConnection()==0) 00645 { 00646 bbtkError("** Checking Connection "<<(void*)this 00647 <<" ["<<GetFullName()<<"] : " 00648 <<" InputConnector '" 00649 <<mInput<<"' of "<<mTo->bbGetName() 00650 <<" does not point to this connection"); 00651 00652 } 00653 bbtkMessage("debug",2," - To : This connection is in InputConnector connection vector"<<std::endl); 00654 bbtkMessage("debug",2," * Box to : Check successfull"<<std::endl); 00655 00656 } 00657 }
BlackBoxPointer bbtk::Connection::GetBlackBoxFrom | ( | ) | const [inline] |
Returns the initial black box of the connection.
Definition at line 111 of file bbtkConnection.h.
00111 { return mFrom; }
const std::string& bbtk::Connection::GetBlackBoxFromOutput | ( | ) | const [inline] |
Returns the output of the initial black box of the connection.
Definition at line 115 of file bbtkConnection.h.
00115 { return mOutput; }
BlackBoxPointer bbtk::Connection::GetBlackBoxTo | ( | ) | const [inline] |
Returns the final black box of the connection.
Definition at line 113 of file bbtkConnection.h.
00113 { return mTo; }
const std::string& bbtk::Connection::GetBlackBoxToInput | ( | ) | const [inline] |
Returns the input of the final black box of the connection.
Definition at line 117 of file bbtkConnection.h.
00117 { return mInput; }
std::string bbtk::Connection::GetFullName | ( | ) | const |
Definition at line 534 of file bbtkConnection.cxx.
References mFrom, mInput, mOriginalFrom, mOriginalInput, mOriginalOutput, mOriginalTo, mOutput, and mTo.
Referenced by bbtk::ComplexBlackBox::bbConnectInput(), bbtk::BlackBox::bbConnectInput(), bbtk::ComplexBlackBox::bbConnectOutput(), bbtk::BlackBox::bbConnectOutput(), bbtk::BlackBox::bbDisconnectInput(), bbtk::BlackBox::bbDisconnectOutput(), Check(), GetObjectName(), and TransferData().
00534 { 00535 if (mFrom && mTo) 00536 { 00537 std::string res = mFrom->bbGetName()+"."+mOutput+"--" 00538 +mTo->bbGetName()+"."+mInput; 00539 if ((!mOriginalFrom.expired()) && (!mOriginalTo.expired()) && 00540 ((mFrom!=mOriginalFrom.lock())||(mTo!=mOriginalTo.lock()))) 00541 { 00542 res += "("+mOriginalFrom.lock()->bbGetName() 00543 +"."+mOriginalOutput+"--" 00544 + mOriginalTo.lock()->bbGetName()+"."+mOriginalInput+")"; 00545 } 00546 return res; 00547 } 00548 return "***Invalid Connection***"; 00549 }
std::string bbtk::Connection::GetObjectInfo | ( | ) | const [virtual] |
Reimplemented from bbtk::Object.
Definition at line 670 of file bbtkConnection.cxx.
References bbtk::i.
00671 { 00672 std::stringstream i; 00673 return i.str(); 00674 }
size_t bbtk::Connection::GetObjectInternalSize | ( | ) | const [virtual] |
Reimplemented from bbtk::Object.
Definition at line 686 of file bbtkConnection.cxx.
Referenced by GetObjectRecursiveSize(), and GetObjectSize().
00687 { 00688 size_t s = sizeof(Connection); 00689 return s; 00690 }
std::string bbtk::Connection::GetObjectName | ( | ) | const [virtual] |
Reimplemented from bbtk::Object.
Definition at line 660 of file bbtkConnection.cxx.
References GetFullName().
00661 { 00662 std::string s("Connection '"); 00663 s += GetFullName(); 00664 s += "'"; 00665 return s; 00666 }
size_t bbtk::Connection::GetObjectRecursiveSize | ( | ) | const [virtual] |
Reimplemented from bbtk::Object.
Definition at line 693 of file bbtkConnection.cxx.
References GetObjectInternalSize(), and bbtk::Object::GetObjectRecursiveSize().
00694 { 00695 size_t s = Superclass::GetObjectRecursiveSize(); 00696 s += Connection::GetObjectInternalSize(); 00697 return s; 00698 }
static long bbtk::Object::GetObjectsCount | ( | ) | [inline, static, inherited] |
Definition at line 75 of file bbtkObject.h.
Referenced by bbtk::StaticInitTime::~StaticInitTime().
00075 { return mgObjectList.size(); }
size_t bbtk::Connection::GetObjectSize | ( | ) | const [virtual] |
Reimplemented from bbtk::Object.
Definition at line 678 of file bbtkConnection.cxx.
References GetObjectInternalSize(), and bbtk::Object::GetObjectSize().
00679 { 00680 size_t s = Superclass::GetObjectSize(); 00681 s += Connection::GetObjectInternalSize(); 00682 return s; 00683 }
BlackBoxPointer bbtk::Connection::GetOriginalBlackBoxFrom | ( | ) | const [inline] |
Returns the original initial black box of the connection.
Definition at line 102 of file bbtkConnection.h.
Referenced by bbtk::BlackBox::bbPrintHelp(), bbtk::ComplexBlackBox::bbWriteDotFileBlackBox(), and bbtk::BlackBox::bbWriteDotFileBlackBox().
00102 { return mOriginalFrom.lock(); }
const std::string& bbtk::Connection::GetOriginalBlackBoxFromOutput | ( | ) | const [inline] |
Returns the original output of the initial black box of the connection.
Definition at line 106 of file bbtkConnection.h.
Referenced by bbtk::BlackBox::bbPrintHelp(), bbtk::ComplexBlackBox::bbWriteDotFileBlackBox(), and bbtk::BlackBox::bbWriteDotFileBlackBox().
00106 { return mOriginalOutput; }
BlackBoxPointer bbtk::Connection::GetOriginalBlackBoxTo | ( | ) | const [inline] |
Returns the origianl final black box of the connection.
Definition at line 104 of file bbtkConnection.h.
Referenced by bbtk::ComplexBlackBox::bbWriteDotFileBlackBox(), and bbtk::BlackBox::bbWriteDotFileBlackBox().
00104 { return mOriginalTo.lock(); }
const std::string& bbtk::Connection::GetOriginalBlackBoxToInput | ( | ) | const [inline] |
Returns the original input of the final black box of the connection.
Definition at line 108 of file bbtkConnection.h.
Referenced by bbtk::ComplexBlackBox::bbWriteDotFileBlackBox(), and bbtk::BlackBox::bbWriteDotFileBlackBox().
00108 { return mOriginalInput; }
boost::shared_ptr<U> bbtk::Object::GetThisPointer | ( | ) | const [inline, protected, inherited] |
Definition at line 92 of file bbtkObject.h.
00093 { 00094 return boost::dynamic_pointer_cast<U>(mThisPointer.lock()); 00095 }
long bbtk::Object::GetUseCount | ( | ) | [inline, inherited] |
void bbtk::Object::InsertInObjectList | ( | Pointer | p | ) | [static, inherited] |
Definition at line 59 of file bbtkObject.cxx.
References bbtkDebugMessage, and bbtk::Object::mgObjectList.
Referenced by bbtk::Object::MakePointer().
00060 { 00061 bbtkDebugMessage("object",9,"##> Object::InsertInObjectList(\"" 00062 <<p->GetObjectName()<<"\" ["<<p<<"])"<<std::endl); 00063 boost::weak_ptr<Object> w(p); 00064 mgObjectList.insert(w); 00065 }
void bbtk::Object::InsertInPackageList | ( | Pointer | p | ) | [static, inherited] |
Definition at line 69 of file bbtkObject.cxx.
References bbtkDebugMessage, and bbtk::Object::mgPackageList.
00070 { 00071 bbtkDebugMessage("object",9,"##> Object::InsertInPackageList(\"" 00072 <<p->GetObjectName()<<"\" ["<<p<<"])"<<std::endl); 00073 boost::weak_ptr<Object> w(p); 00074 mgPackageList.insert(w); 00075 }
void bbtk::Object::LockThis | ( | ) | [inline, protected, inherited] |
static boost::shared_ptr<U> bbtk::Object::MakePointer | ( | U * | s, | |
const D & | del, | |||
bool | lock = false | |||
) | [inline, static, protected, inherited] |
Definition at line 115 of file bbtkObject.h.
References bbtk::Object::InsertInObjectList().
00118 { 00119 if (s->mThisPointer.lock()) 00120 { 00121 boost::shared_ptr<U> p = s->GetThisPointer<U>(); 00122 if (!lock) s->mThisPointerLocked.reset(); 00123 return p; 00124 } 00125 boost::shared_ptr<U> p = boost::shared_ptr<U>(s,del); 00126 static_cast<D*> 00127 (p._internal_get_deleter(typeid(D))) 00128 ->mPointer = p; 00129 s->mThisPointer = p; 00130 Object::InsertInObjectList(p); 00131 if (lock) s->LockThis(); 00132 return p; 00133 }
static boost::shared_ptr<U> bbtk::Object::MakePointer | ( | U * | s, | |
bool | lock = false | |||
) | [inline, static, protected, inherited] |
Definition at line 97 of file bbtkObject.h.
References bbtk::Object::InsertInObjectList().
Referenced by bbtk::ComplexBlackBoxDescriptor::ComplexBlackBoxDescriptor(), bbtk::Executer::Executer(), bbtk::Interpreter::Init(), bbtk::Transcriptor::New(), bbtk::Package::New(), bbtk::InterpreterVirtual::New(), bbtk::Interpreter::New(), bbtk::Factory::New(), bbtk::Executer::New(), and bbtk::ComplexBlackBoxDescriptor::New().
00098 { 00099 if (s->mThisPointer.lock()) 00100 { 00101 boost::shared_ptr<U> p = s->GetThisPointer<U>(); 00102 if (!lock) s->mThisPointerLocked.reset(); 00103 return p; 00104 } 00105 boost::shared_ptr<U> p = boost::shared_ptr<U>(s,Object::Deleter()); 00106 static_cast<Object::Deleter*> 00107 (p._internal_get_deleter(typeid(Object::Deleter))) 00108 ->mPointer = p; 00109 s->mThisPointer = p; 00110 Object::InsertInObjectList(p); 00111 if (lock) s->LockThis(); 00112 return p; 00113 }
static Pointer bbtk::Connection::New | ( | BlackBoxPointer | from, | |
const std::string & | output, | |||
BlackBoxPointer | to, | |||
const std::string & | input | |||
) | [static] |
static Pointer bbtk::Connection::New | ( | BlackBoxPointer | from, | |
const std::string & | output, | |||
BlackBoxPointer | to, | |||
const std::string & | input, | |||
const FactoryPointer | f | |||
) | [static] |
void bbtk::Connection::OnOutputChange | ( | BlackBoxPointer | , | |
const std::string & | , | |||
IOStatus | ||||
) |
Change callback.
void bbtk::Object::PrintObjectInfo | ( | const Pointer & | o | ) | [static, inherited] |
Definition at line 180 of file bbtkObject.cxx.
Referenced by bbtk::Object::PrintObjectListInfo().
00181 { 00182 std::cout << "* [" << p << "] \t" 00183 << p.use_count()-1 << " r \t" 00184 << p->GetObjectRecursiveSize() << " (" 00185 << p->GetObjectSize() << ") b \t" 00186 << p->GetObjectName() 00187 << std::endl; 00188 std::cout << p->GetObjectInfo(); 00189 }
void bbtk::Object::PrintObjectListInfo | ( | const std::string & | name | ) | [static, inherited] |
Definition at line 105 of file bbtkObject.cxx.
References bbtk::i, bbtk::Object::mgObjectList, and bbtk::Object::PrintObjectInfo().
Referenced by bbtk::Interpreter::commandDebug().
00106 { 00107 00108 std::cout 00109 << "=============== Living bbtk::Object pointers ========="<<std::endl; 00110 00111 long n = 0; 00112 long u = 0; 00113 size_t m = 0; 00114 ObjectListType::iterator i; 00115 for (i = mgObjectList.begin(); 00116 i!=mgObjectList.end(); 00117 ++i) 00118 { 00119 if (i->use_count() == 0) 00120 { 00121 u++; 00122 } 00123 else 00124 { 00125 Object::Pointer p(i->lock()); 00126 if (p->GetObjectName().find(name) != std::string::npos ) 00127 { 00128 std::cout << n << "/" << mgObjectList.size() << " "; 00129 PrintObjectInfo(p); 00130 m += p->GetObjectSize(); 00131 n++; 00132 } 00133 } 00134 } 00135 std::cout 00136 << "------------------------------------------------------"<<std::endl; 00137 00138 std::cout << " Total : "<<n<<" objects - "<<m<<" b"<<std::endl; 00139 if (u==1) 00140 { 00141 std::cout<<"* Note : "<<u 00142 <<" object in list has 0 ref count, " 00143 <<"i.e. are no more accessible by bbtk but did not properly destroyed because another ref counting system is holding them !"<<std::endl; 00144 } 00145 else if (u>1) 00146 { 00147 std::cout<<"* Note : "<<u 00148 <<" objects in list have 0 ref count, " 00149 <<"i.e. are no more accessible by bbtk but did not properly destroyed because another ref counting system is holding them !"<<std::endl; 00150 } 00151 std::cout 00152 << "============ EO Living bbtk::Object pointers ========="<<std::endl; 00153 00154 }
void bbtk::Connection::RecursiveExecute | ( | ) |
Dtor.
Recursive execution.
Pipeline processing method 1) call bbRecursiveExecute(this) on the from box 2) copies the from box output to the to box input adapting it if needed 3) sets the new IOStatus of the to box input to the status of the from box output
Definition at line 345 of file bbtkConnection.cxx.
References bbtkCDebugMessage, bbtk::GetIOStatusString(), mFrom, mInput, bbtk::MODIFIED, mOutput, mTo, bbtk::OUTOFDATE, and TransferData().
Referenced by bbtk::BlackBoxInputConnector::RecursiveExecute().
00346 { 00347 bbtkCDebugMessage("process",4, 00348 "===> Connection::RecursiveExecute()" 00349 <<std::endl); 00350 00351 /* 00352 // If box from already executing : nothing to do 00353 if (mFrom->bbGetExecuting()) 00354 { 00355 bbtkDebugMessage("process",3, 00356 " -> "<<mFrom->bbGetName() 00357 <<" already executing : abort"<<std::endl); 00358 return; 00359 00360 } 00361 */ 00362 00363 mFrom->bbRecursiveExecute(GetThisPointer<Connection>()); 00364 00365 TransferData(); 00366 00367 // Transfer status 00368 IOStatus s = MODIFIED; 00369 if ( mFrom->bbGetOutputConnector(mOutput).GetStatus() == OUTOFDATE) 00370 { 00371 s = OUTOFDATE; 00372 } 00373 mTo->bbGetInputConnector(mInput).SetStatus(s); 00374 00375 bbtkCDebugMessage("process",4, 00376 " --> '"<<mTo->bbGetName()<<"."<<mInput 00377 <<" ["<<&mTo->bbGetInputConnector(mInput)<<"] " 00378 <<"' new status '" 00379 <<GetIOStatusString(s) 00380 <<"'" 00381 << std::endl); 00382 00383 bbtkCDebugMessage("process",4, 00384 "<=== Connection::RecursiveExecute()" 00385 <<std::endl); 00386 return; 00387 }
void bbtk::Object::ReleasePackages | ( | ) | [static, inherited] |
Definition at line 222 of file bbtkObject.cxx.
References bbtkDebugMessage, bbtk::i, bbtk::Object::mgPackageList, and bbtk::Package::Release().
Referenced by bbtk::StaticInitTime::~StaticInitTime().
00223 { 00224 bbtkDebugMessage("object",1,"##> Object::ReleasePackages()"<<std::endl); 00225 // Release package pointers 00226 ObjectListType::iterator i; 00227 for (i = mgPackageList.begin(); 00228 i!= mgPackageList.end(); 00229 ++i) 00230 { 00231 if (i->use_count() != 0) 00232 { 00233 bbtkDebugMessage("object",1,"##> Releasing package '"<< 00234 i->lock()->GetThisPointer<Package>()->GetName() 00235 <<"'"<<std::endl); 00236 // Object::Pointer p(i->lock()); 00237 Package::WeakPointer w(i->lock()->GetThisPointer<Package>()); 00238 Package::Release(w); 00239 /* 00240 if (p->GetObjectName().find(name) != std::string::npos ) 00241 { 00242 std::cout << n << "/" << mgObjectList.size() << " "; 00243 PrintObjectInfo(p); 00244 m += p->GetObjectSize(); 00245 n++; 00246 } 00247 */ 00248 } 00249 } 00250 00251 }
void bbtk::Object::RemoveFromObjectList | ( | WeakPointer | p | ) | [static, inherited] |
Definition at line 80 of file bbtkObject.cxx.
References bbtkDebugMessage, and bbtk::Object::mgObjectList.
Referenced by bbtk::Object::Deleter::operator()().
00081 { 00082 bbtkDebugMessage("object",9,"##> Object::RemoveFromObjectList()" 00083 <<std::endl); 00084 mgObjectList.erase(p); 00085 00086 }
void bbtk::Connection::SetBlackBoxFrom | ( | BlackBoxPointer | b | ) | [inline] |
Sets the initial black box of the connection.
Definition at line 120 of file bbtkConnection.h.
Referenced by bbtk::ComplexBlackBox::bbConnectOutput().
00120 { mFrom = b; }
void bbtk::Connection::SetBlackBoxFromOutput | ( | const std::string & | o | ) | [inline] |
Sets the output of the initial black box of the connection.
Definition at line 124 of file bbtkConnection.h.
Referenced by bbtk::ComplexBlackBox::bbConnectOutput().
00124 { mOutput = o; }
void bbtk::Connection::SetBlackBoxTo | ( | BlackBoxPointer | b | ) | [inline] |
Sets the final black box of the connection.
Definition at line 122 of file bbtkConnection.h.
Referenced by bbtk::ComplexBlackBox::bbConnectInput().
00122 { mTo = b; }
void bbtk::Connection::SetBlackBoxToInput | ( | const std::string & | o | ) | [inline] |
Sets the input of the final black box of the connection.
Definition at line 126 of file bbtkConnection.h.
Referenced by bbtk::ComplexBlackBox::bbConnectInput().
00126 { mInput = o; }
void bbtk::Connection::TransferData | ( | ) |
Ctor with the black box from and to and their input and output and a dummy int to differentiate from the public constructor. Sets the members but does not test compatibility (used by bbtk::AdaptiveConnection)
Transfers the data from the source output to the target input doing necessary conversions (adaptation or pointer cast)
Definition at line 395 of file bbtkConnection.cxx.
References bbtkCDebugMessage, bbtkError, GetFullName(), bbtk::HumanTypeName(), mAdaptor, mFactory, mFrom, mFromAny, mInput, mOutput, mTo, and mToAny.
Referenced by RecursiveExecute().
00396 { 00397 bbtkCDebugMessage("data",3, 00398 "Connection::TransferData()" 00399 <<std::endl); 00400 00401 00402 // If an adaptor was created we need to adapt the data 00403 if (mAdaptor) 00404 { 00405 mAdaptor->bbSetInput("In",mFrom->bbGetOutput(mOutput),false); 00406 mAdaptor->bbExecute(); 00407 // LG : Connection Update does not set mTo as modified 00408 mTo->bbSetInput(mInput, mAdaptor->bbGetOutput("Out"),false); 00409 00410 } 00411 // If no adaptor but source type is an any and target is not an any 00412 else if ( mFromAny && (! mToAny) ) 00413 { 00414 bbtkCDebugMessage("data",3, 00415 " * Source type is an " 00416 <<HumanTypeName<Data>() 00417 <<" which contains a <" 00418 <<HumanTypeName(mFrom->bbGetOutput(mOutput).type()) 00419 <<">"<<std::endl); 00420 bbtkCDebugMessage("data",3, 00421 " * Target type is <" 00422 <<HumanTypeName(mTo->bbGetInputType(mInput)) 00423 <<">"<<std::endl); 00424 00425 // 0) If from any contents void : nothing to do 00426 if (mFrom->bbGetOutput(mOutput).type() == typeid(void)) 00427 { 00428 bbtkCDebugMessage("data",3, 00429 " -> Source is void : nothing to transfer!"<<std::endl); 00430 } 00431 // 1) Test strict type matching between any content and target 00432 else if (mFrom->bbGetOutput(mOutput) 00433 .contains( mTo->bbGetInputType(mInput) ) ) 00434 { 00435 bbtkCDebugMessage("data",3, 00436 " -> Equal types : transfer ok"<<std::endl); 00437 mTo->bbSetInput( mInput, 00438 mFrom->bbGetOutput(mOutput), 00439 false); 00440 } 00441 else 00442 { 00443 // 2) Look for an adaptor 00444 bbtk::BlackBox::Pointer adaptor; 00445 try 00446 { 00447 adaptor = mFactory.lock() 00448 ->NewAdaptor(mFrom->bbGetOutput(mOutput).type(), 00449 mTo->bbGetInputType(mInput), 00450 ""); 00451 } 00452 catch (...) 00453 { 00454 } 00455 if (adaptor) 00456 { 00457 bbtkCDebugMessage("data",3," -> Adaptor found : using it" 00458 <<std::endl); 00459 adaptor->bbSetInput("In",mFrom->bbGetOutput(mOutput),false); 00460 adaptor->bbExecute(); 00461 // LG : Connection Update does not set mTo as modified 00462 mTo->bbSetInput(mInput, adaptor->bbGetOutput("Out"),false); 00463 // adaptor->bbDelete(); 00464 } 00465 // 3) If no adaptor found but the any content is a pointer 00466 // and target type is also a pointer : we try run-time cast 00467 else if ( (mFrom->bbGetOutput(mOutput).contains_pointer()) && 00468 (mTo->bbGetDescriptor()->GetInputDescriptor(mInput) 00469 ->IsPointerType()) ) 00470 { 00471 bbtkCDebugMessage("data",3, 00472 " -> No adaptor found but source and target types are both pointers : trying up or down cast"<<std::endl); 00473 00474 void* nptr = 00475 mFrom->bbGetOutput(mOutput) 00476 .get_pointer_to(mTo->bbGetInput(mInput).pointed_type()); 00477 if (!nptr) 00478 { 00479 bbtkError("Connection '" 00480 <<GetFullName() 00481 <<"' : <" 00482 <<HumanTypeName(mFrom->bbGetOutput(mOutput).type()) 00483 <<"> to <" 00484 <<HumanTypeName(mTo->bbGetInputType(mInput)) 00485 <<"> : no adaptor available and run-time up and down cast failed"); 00486 } 00487 mTo->bbBruteForceSetInputPointer(mInput, nptr, false); 00488 } 00489 // 4) Nothing worked : error 00490 else 00491 { 00492 bbtkError("Connection '"<<GetFullName()<<"' " 00493 <<"no adaptor found to convert <" 00494 <<HumanTypeName(mFrom->bbGetOutput(mOutput).type()) 00495 <<"> to <" 00496 <<HumanTypeName(mTo->bbGetInputType(mInput))<<">"); 00497 } 00498 } 00499 } 00500 // EO : mFromAny && ! mToAny 00501 // Default case : types are the same; we use simple get-set 00502 else 00503 { 00504 // LG : Connection Update does not set mTo as modified 00505 mTo->bbSetInput(mInput, mFrom->bbGetOutput(mOutput),false); 00506 } 00507 00508 }
void bbtk::Object::UnLockThis | ( | ) | [inline, protected, inherited] |
friend struct Object::Deleter [friend] |
Definition at line 73 of file bbtkConnection.h.
BlackBoxPointer bbtk::Connection::mAdaptor [protected] |
Input connector of mTo which is connected.
Adaptor black box if needed
Definition at line 149 of file bbtkConnection.h.
Referenced by TransferData(), and ~Connection().
bool bbtk::Connection::mDoDynamicCast [protected] |
const FactoryWeakPointer bbtk::Connection::mFactory [protected] |
The factory used to create adaptors.
Definition at line 152 of file bbtkConnection.h.
Referenced by TransferData().
BlackBoxPointer bbtk::Connection::mFrom [protected] |
Black box origin of the connection.
Definition at line 133 of file bbtkConnection.h.
Referenced by Check(), GetFullName(), RecursiveExecute(), TransferData(), and ~Connection().
bool bbtk::Connection::mFromAny [protected] |
Is the connection input type is any<thing> ?
Definition at line 155 of file bbtkConnection.h.
Referenced by TransferData().
std::string bbtk::Connection::mInput [protected] |
Input of mTo which is connected.
Definition at line 144 of file bbtkConnection.h.
Referenced by Check(), GetFullName(), RecursiveExecute(), TransferData(), and ~Connection().
BlackBoxWeakPointer bbtk::Connection::mOriginalFrom [protected] |
std::string bbtk::Connection::mOriginalInput [protected] |
std::string bbtk::Connection::mOriginalOutput [protected] |
BlackBoxWeakPointer bbtk::Connection::mOriginalTo [protected] |
std::string bbtk::Connection::mOutput [protected] |
Output of mFrom which is connected.
Definition at line 136 of file bbtkConnection.h.
Referenced by Check(), GetFullName(), RecursiveExecute(), TransferData(), and ~Connection().
BlackBoxPointer bbtk::Connection::mTo [protected] |
Output connector of mFrom which is connected.
Black box destination of the connection
Definition at line 141 of file bbtkConnection.h.
Referenced by Check(), GetFullName(), RecursiveExecute(), TransferData(), and ~Connection().
bool bbtk::Connection::mToAny [protected] |
Is the connection output type is any<thing> ?
Definition at line 158 of file bbtkConnection.h.
Referenced by TransferData().