|
Go to the documentation of this file.
28 #ifndef FAUDES_MUTE_RTIAUTOLOAD
35 #include "allplugins.h"
36 #include "rtiautoload.h"
37 #include "rtiautoload.cpp"
65 FD_DREG( "TypeRegistry(): Constrtuct singleton");
73 FD_DREG( "TypeRegistry::Clear(): begin with #" << Size());
75 std::map<std::string, TypeDefinition*>::iterator mit;
77 if(mit->second != NULL)
78 if(!mit->second->AutoRegistered()){
82 if(mit->second != NULL)
83 if(mit->second->AutoRegistered()){
84 FD_DREG( "TypeRegistry::Clear(): detect autoreg " << mit->second->Name());
88 std::map<std::string, TypeDefinition*>::iterator dit;
98 FD_DREG( "TypeRegistry::Clear(): keeping " << ptdef-> Name());
107 FD_DREG( "TypeRegistry::ClearAll()");
109 std::map<std::string, TypeDefinition*>::iterator mit;
111 if(mit->second != NULL){
138 #ifdef FAUDES_DEBUG_REGISTRY
140 FD_DREG( "TypeRegistry::Insert(): definition for " << pTypeDef-> Name());
142 FD_DREG( "TypeRegistry::Insert(): dummy prototype for " << pTypeDef-> Name());
150 if((pt!=0) && (opt!=0))
151 if( typeid(*pt).name() == typeid(*opt).name()) {
152 FD_DREG( "TypeRegistry::Insert(): ignoring doublet " << pTypeDef-> Name());
158 std::stringstream err;
159 err << "Cannot overwrite existing entry with type " << pTypeDef-> Name() << std::endl;
160 throw Exception( "TypeRegistry::Insert()", err.str(), 46);
163 if(pTypeDef-> Name()== "") {
164 std::stringstream err;
165 err << "Cannot have empty name"<< std::endl;
166 throw Exception( "TypeRegistry::Insert()", err.str(), 46);
179 FD_DV( "TypeRegistry::MergeDocumentation(): using " << rTr. FileName());
182 while(rTr. Peek(token)) {
184 if(!token.IsBegin( "TypeDefinition")) { rTr. Get(token); continue; }
185 if(!token.ExistsAttributeString( "name")) { rTr. Get(token); continue; }
187 std::string ftype=token.AttributeStringValue( "name");
188 size_t pos=ftype.find( "::");
189 if(pos!=std::string::npos) ftype=ftype.substr(pos+2);
190 FD_DRTI( "TypeRegistry::MergeDocumentation(): " << ftype);
195 tit->second->MergeDocumentation(rTr);
215 if(mit == End()) return;
216 mit->second->XElementTag(rTag);
222 static std::string estr= "";
223 if(mit == End()) return estr;
224 return mit->second->XElementTag();
232 FD_DREG( "TypeRegistry::AutoRegistered(...): cannot access definition for faudes type " << rTypeName);
235 mit->second->AutoRegistered(flag);
241 if(mit == End()) return false;
242 return mit->second->AutoRegistered();
248 FD_DRTI( "TypeRegistry::NewObject(\"" << rName << "\")");
251 std::stringstream err;
252 err << "Unknown Type " << rName << std::endl;
253 throw Exception( "TypeRegistry::NewObject()", err.str(), 47);
255 Type* res=mit->second->NewObject();
257 std::stringstream err;
258 err << "Failed to instatiate new " << rName << std::endl;
259 throw Exception( "TypeRegistry::NewObject()", err.str(), 47);
266 FD_DRTI( "TypeRegistry::NewObject(prototype): typeid " << typeid(rType).name());
270 std::stringstream err;
271 err << "Unknown type by reference" << std::endl;
272 throw Exception( "TypeRegistry::NewObject()", err.str(), 47);
279 FD_DRTI( "TypeRegistry::Definition( " << rName << " )");
282 std::stringstream err;
283 err << "Type not found: \"" << rName << "\"";
284 throw Exception( "TypeRegistry::Definition()", err.str(), 46);
286 return(*(mit->second));
291 FD_DRTI( "TypeRegistry::Definition(): typeid " << typeid(rType).name());
295 std::stringstream err;
296 err << "Type not found: " << typeid(rType).name();
297 throw Exception( "TypeRegistry::Definition()", err.str(), 46);
302 FD_DRTI( "TypeRegistry::Definitionp( " << rName << " )");
304 if(mit == End()) return NULL;
310 FD_DRTI( "TypeRegistry::Definitionp(): typeid " << typeid(rType).name());
319 FD_DRTI( "TypeRegistry::Prototype( " << rName << " )");
321 if(mit == End()) return 0;
322 return(mit->second->Prototype());
327 FD_DRTI( "TypeRegistry::TypeName(): typeid " << typeid(rType).name());
331 static std::string empty( "");
337 FD_DRTI( "TypeRegistry::TypeTest(): typeid " << typeid(rObject).name());
339 if(mit == End()) return false;
340 if(!mit->second->Prototype()) return false;
341 FD_DRTI( "TypeRegistry::TypeTest(): dst ftype " << rTypeName<< " src typeid " << typeid(rObject).name()
342 << " res " << (mit->second->Prototype()->Cast(&rObject) != 0));
343 return ( mit->second->Prototype()->Cast(&rObject) != 0 );
367 rTw. WriteXmlComment( "===================================================");
368 rTw. WriteXmlComment( "===================================================");
370 rTw. WriteXmlComment( "===================================================");
371 rTw. WriteXmlComment( "===================================================");
373 tit->second->Write(rTw);
399 FD_DREG( "FunctionRegistry(): Construct singleton");
407 FD_DREG( "FunctionRegistry::Clear()");
409 std::map<std::string, FunctionDefinition*>::iterator mit;
411 if(mit->second != NULL) {
412 FD_DREG( "FunctionRegistry::Clear: removing " << mit->second->Name());
439 #ifdef FAUDES_DEBUG_REGISTRY
441 FD_DREG( "FunctionRegistry::Insert(): definition for " << pFunctionDef-> Name());
443 FD_DREG( "FunctionRegistry::Insert(): fake entry for " << pFunctionDef-> Name());
448 std::stringstream err;
449 err << "Cannot overwrite existing entry with function " << pFunctionDef-> Name() << std::endl;
450 throw Exception( "FunctionRegistry::Insert()", err.str(), 46);
453 if(pFunctionDef-> Name()== "") {
454 std::stringstream err;
455 err << "Cannot have empty name"<< std::endl;
456 throw Exception( "FunctionRegistry::Insert()", err.str(), 46);
468 FD_DREG( "FunctionRegistry::MergeDocumentation(): using " << rTr. FileName());
471 while(rTr. Peek(token)) {
475 { rTr. Get(token); continue; }
476 if((token.StringValue()!= "FunctionDefinition") && (token.StringValue()!= "LuaFunctionDefinition"))
477 { rTr. Get(token); continue; }
478 if(!token.ExistsAttributeString( "name"))
479 { rTr. Get(token); continue; }
481 std::string ffunction=token.AttributeStringValue( "name");
482 size_t pos=ffunction.find( "::");
483 if(pos!=std::string::npos) ffunction=ffunction.substr(pos+2);
488 fit->second->MergeDocumentation(rTr);
508 FD_DRTI( "FunctionRegistry::NewFunction(\"" << rName << "\")");
511 std::stringstream err;
512 err << "Unknown function " << rName << std::endl;
513 throw Exception( "FunctionRegistry::NewFunction()", err.str(), 47);
515 Function* res=mit->second->NewFunction();
517 std::stringstream err;
518 err << "Failed to instatiate new " << rName << std::endl;
519 throw Exception( "FunctionRegistry::NewFunction()", err.str(), 47);
526 FD_DRTI( "FunctionRegistry::NewFunction(prototype): typeid " << typeid(rFunction).name());
530 std::stringstream err;
531 err << "Unknown function by reference" << std::endl;
532 throw Exception( "FunctionRegistry::NewFunction()", err.str(), 47);
534 return(rFunction. New());
539 FD_DRTI( "FunctionRegistry::Definition( " << rName << " )");
542 std::stringstream err;
543 err << "Function not found: " << rName;
544 throw Exception( "FunctionRegistry::Definition()", err.str(), 46);
546 return(*(mit->second));
551 FD_DRTI( "FunctionRegistry::Definition(): typeid " << typeid(rFunction).name());
555 std::stringstream err;
556 err << "Function not found: " << typeid(rFunction).name();
557 throw Exception( "FunctionRegistry::Definition()", err.str(), 46);
562 FD_DRTI( "FunctionRegistry::FunctionName(): typeid " << typeid(rFunction).name());
566 static const std::string empty( "");
591 rTw. WriteXmlComment( "===================================================");
592 rTw. WriteXmlComment( "===================================================");
594 rTw. WriteXmlComment( "===================================================");
595 rTw. WriteXmlComment( "===================================================");
597 tit->second-> Write(rTw);
617 FD_DREG( "LoadRegistry(" << rPath << ")");
619 std::string rtipath = rPath;
620 if(rtipath== "") rtipath= "./libfaudes.rti";
626 #ifndef FAUDES_MUTE_RTIAUTOLOAD
627 LoadRegisteredTypes();
632 #ifdef FAUDES_PLUGINS_RTILOAD
633 FAUDES_PLUGINS_RTILOAD;
638 #ifndef FAUDES_MUTE_RTIAUTOLOAD
639 LoadRegisteredFunctions();
647 #ifdef FAUDES_CHECKED
648 #ifndef FAUDES_MUTE_RTIAUTOLOAD
652 if(tit->second->PlugIn()!= "IODevice")
653 if(tit->second->Prototype()==NULL)
654 FD_WARN( "TypeRegistry: " << tit->second->Name() << " has no prototype");
659 if(fit->second->Prototype()==NULL)
660 FD_WARN( "FunctionRegistry: " << fit->second->Name() << " has no prototype");
665 FD_DREG( "LoadRegistry(" << rPath << "): done");
671 FD_DRTI( "SaveRegistry(" << rPath << ")");
libFAUDES 2.28a
--- 2016.09.13
--- c++ api documentaion by doxygen
|