13 #include "../scheduling/Clock.h"
17 unsigned int n,
bool toGlobal,
bool copyExtMsg )
19 if ( newName.length() > 0 && !
isNameValid( newName ) ) {
20 cout <<
"Error: Shell::doCopy: Illegal name for copy.\n";
25 cout <<
"Error: Shell::doCopy: Cannot copy object to descendant in tree\n";
29 cout <<
"Warning: Shell::doCopy( " << orig.
path() <<
" to " <<
30 newParent.
path() <<
" ) : numCopies must be > 0, using 1 \n";
34 cout <<
"Error: Shell::doCopy: Cannot copy object '" << newName <<
35 "' onto '" << newParent.
path() <<
36 "' since object with same name already present.\n";
43 args.push_back( orig );
44 args.push_back( newParent );
45 args.push_back( newElm );
48 args, newName, n, toGlobal, copyExtMsg );
63 unsigned int n,
bool toGlobal, map< Id, Id >& tree )
68 newParent, newId, newNumData, toGlobal );
74 tree[ orig ] = e->
id();
80 for ( vector< Id >::iterator i = kids.begin(); i != kids.end(); ++i ) {
89 void innerCopyMsgs( map< Id, Id >& tree,
unsigned int n,
bool copyExtMsgs )
105 for ( map< Id, Id >::const_iterator i = tree.begin();
106 i != tree.end(); ++i ) {
107 Element *e = i->first.element();
112 for ( vector< MsgFuncBinding >::const_iterator k =
114 k != b->end(); ++k ) {
125 map< Id, Id >::const_iterator tgt;
126 if ( m->
e1() == e ) {
127 tgt = tree.find( m->
e2()->
id() );
128 }
else if ( m->
e2() == e ) {
129 tgt = tree.find( m->
e1()->
id() );
133 if ( tgt != tree.end() )
134 m->
copy( e->
id(), i->second, tgt->second,
145 unsigned int n,
bool toGlobal,
bool copyExtMsgs )
149 assert( args.size() == 3 );
156 e->setName( newName );
163 string newName,
unsigned int n,
bool toGlobal,
bool copyExtMsgs )
165 if ( !
innerCopy( args, newName, n, toGlobal, copyExtMsgs ) ) {
166 cout <<
"Error on Shell::myNode()::Shell::handleCopy for " <<
167 newName <<
", " << n << endl;
static ObjId parent(const Eref &e)
Element * element() const
Synonym for Id::operator()()
BindIndex getBindIndex() const
std::string path(const std::string &separator="/") const
Id doCopy(Id orig, ObjId newParent, string newName, unsigned int n, bool toGlobal, bool copyExtMsgs)
Returns the Id of the root of the copied tree upon success.
static Id child(const Eref &e, const string &name)
static void children(const Eref &e, vector< Id > &ret)
void handleCopy(const Eref &e, vector< ObjId > args, string newName, unsigned int n, bool toGlobal, bool copyExtMsgs)
void innerCopyMsgs(map< Id, Id > &tree, unsigned int n, bool copyExtMsgs)
virtual Element * copyElement(Id newParent, Id newId, unsigned int n, bool toGlobal) const =0
const std::string & name() const
static bool isDescendant(Id me, Id ancestor)
Element * innerCopyElements(Id orig, ObjId newParent, Id newId, unsigned int n, bool toGlobal, map< Id, Id > &tree)
static unsigned int lookupDefaultTick(const string &className)
const vector< MsgFuncBinding > * getMsgAndFunc(BindIndex b) const
const Cinfo * cinfo() const
virtual unsigned int numData() const =0
Returns number of data entries across all nodes.
static bool adopt(ObjId parent, Id child, unsigned int msgIndex)
bool innerCopy(const vector< ObjId > &args, const string &newName, unsigned int n, bool toGlobal, bool copyExtMsgs)
Does actual work of copying. Returns true on success.
static const Msg * getMsg(ObjId m)
virtual Msg * copy(Id origSrc, Id newSrc, Id newTgt, FuncId fid, unsigned int b, unsigned int n) const =0
static const Cinfo * initCinfo()
static bool isNameValid(const string &name)
const Finfo * findFinfo(const string &name) const