|
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;
97 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());
149 FD_DREG( "TypeRegistry::Insert(): ignore doublet " << pTypeDef-> Name());
155 std::stringstream err;
156 err << "Cannot overwrite existing entry with type " << pTypeDef-> Name() << std::endl;
157 throw Exception( "TypeRegistry::Insert()", err.str(), 46);
160 if(pTypeDef-> Name()== "") {
161 std::stringstream err;
162 err << "Cannot have empty name"<< std::endl;
163 throw Exception( "TypeRegistry::Insert()", err.str(), 46);
177 FD_DREG( "TypeRegistry::MergeDocumentation(): using " << rTr. FileName());
180 while(rTr. Peek(token)) {
182 if(!token.IsBegin()) { rTr. Get(token); continue; }
183 if(token.StringValue()!= "TypeDefinition") { rTr. Get(token); continue; }
184 if(!token.ExistsAttributeString( "name")) { rTr. Get(token); continue; }
186 std::string ftype=token.AttributeStringValue( "name");
187 size_t pos=ftype.find( "::");
188 if(pos!=std::string::npos) ftype=ftype.substr(pos+2);
189 FD_DRTI( "TypeRegistry::MergeDocumentation(): " << ftype);
194 tit->second->MergeDocumentation(rTr);
214 if(mit == End()) return;
215 mit->second->XElementTag(rTag);
221 static std::string estr= "";
222 if(mit == End()) return estr;
223 return mit->second->XElementTag();
231 FD_DREG( "TypeRegistry::AutoRegistered(...): cannot access definition for faudes type " << rTypeName);
234 mit->second->AutoRegistered(flag);
240 if(mit == End()) return false;
241 return mit->second->AutoRegistered();
247 FD_DRTI( "TypeRegistry::NewObject(\"" << rName << "\")");
250 std::stringstream err;
251 err << "Unknown Type " << rName << std::endl;
252 throw Exception( "TypeRegistry::NewObject()", err.str(), 47);
254 Type* res=mit->second->NewObject();
256 std::stringstream err;
257 err << "Failed to instatiate new " << rName << std::endl;
258 throw Exception( "TypeRegistry::NewObject()", err.str(), 47);
265 FD_DRTI( "TypeRegistry::NewObject(prototype): typeid " << typeid(rType).name());
269 std::stringstream err;
270 err << "Unknown type by reference" << std::endl;
271 throw Exception( "TypeRegistry::NewObject()", err.str(), 47);
278 FD_DRTI( "TypeRegistry::Definition( " << rName << " )");
281 std::stringstream err;
282 err << "Type not found: \"" << rName << "\"";
283 throw Exception( "TypeRegistry::Definition()", err.str(), 46);
285 return(*(mit->second));
290 FD_DRTI( "TypeRegistry::Definition(): typeid " << typeid(rType).name());
294 std::stringstream err;
295 err << "Type not found: " << typeid(rType).name();
296 throw Exception( "TypeRegistry::Definition()", err.str(), 46);
301 FD_DRTI( "TypeRegistry::Definitionp( " << rName << " )");
303 if(mit == End()) return NULL;
309 FD_DRTI( "TypeRegistry::Definitionp(): typeid " << typeid(rType).name());
318 FD_DRTI( "TypeRegistry::Prototype( " << rName << " )");
320 if(mit == End()) return 0;
321 return(mit->second->Prototype());
326 FD_DRTI( "TypeRegistry::TypeName(): typeid " << typeid(rType).name());
330 static std::string empty( "");
336 FD_DRTI( "TypeRegistry::TypeTest(): typeid " << typeid(rObject).name());
338 if(mit == End()) return false;
339 if(!mit->second->Prototype()) return false;
340 FD_DRTI( "TypeRegistry::TypeTest(): dst ftype " << rTypeName<< " src typeid " << typeid(rObject).name()
341 << " res " << (mit->second->Prototype()->Cast(&rObject) != 0));
342 return ( mit->second->Prototype()->Cast(&rObject) != 0 );
366 rTw. WriteXmlComment( "===================================================");
367 rTw. WriteXmlComment( "===================================================");
369 rTw. WriteXmlComment( "===================================================");
370 rTw. WriteXmlComment( "===================================================");
372 tit->second-> Write(rTw);
397 FD_DREG( "FunctionRegistry(): Construct singleton");
405 FD_DREG( "FunctionRegistry::Clear()");
407 std::map<std::string, FunctionDefinition*>::iterator mit;
409 if(mit->second != NULL) {
410 FD_DREG( "FunctionRegistry::Clear: removing " << mit->second->Name());
437 #ifdef FAUDES_DEBUG_REGISTRY
439 FD_DREG( "FunctionRegistry::Insert(): definition for " << pFunctionDef-> Name());
446 std::stringstream err;
447 err << "Cannot overwrite existing entry with function " << pFunctionDef-> Name() << std::endl;
448 throw Exception( "FunctionRegistry::Insert()", err.str(), 46);
451 if(pFunctionDef-> Name()== "") {
452 std::stringstream err;
453 err << "Cannot have empty name"<< std::endl;
454 throw Exception( "FunctionRegistry::Insert()", err.str(), 46);
466 FD_DREG( "FunctionRegistry::MergeDocumentation(): using " << rTr. FileName());
469 while(rTr. Peek(token)) {
473 { rTr. Get(token); continue; }
474 if((token.StringValue()!= "FunctionDefinition") && (token.StringValue()!= "LuaFunctionDefinition"))
475 { rTr. Get(token); continue; }
476 if(!token.ExistsAttributeString( "name"))
477 { rTr. Get(token); continue; }
479 std::string ffunction=token.AttributeStringValue( "name");
480 size_t pos=ffunction.find( "::");
481 if(pos!=std::string::npos) ffunction=ffunction.substr(pos+2);
486 fit->second->MergeDocumentation(rTr);
506 FD_DRTI( "FunctionRegistry::NewFunction(\"" << rName << "\")");
509 std::stringstream err;
510 err << "Unknown function " << rName << std::endl;
511 throw Exception( "FunctionRegistry::NewFunction()", err.str(), 47);
513 Function* res=mit->second->NewFunction();
515 std::stringstream err;
516 err << "Failed to instatiate new " << rName << std::endl;
517 throw Exception( "FunctionRegistry::NewFunction()", err.str(), 47);
524 FD_DRTI( "FunctionRegistry::NewFunction(prototype): typeid " << typeid(rFunction).name());
528 std::stringstream err;
529 err << "Unknown function by reference" << std::endl;
530 throw Exception( "FunctionRegistry::NewFunction()", err.str(), 47);
532 return(rFunction. New());
537 FD_DRTI( "FunctionRegistry::Definition( " << rName << " )");
540 std::stringstream err;
541 err << "Function not found: " << rName;
542 throw Exception( "FunctionRegistry::Definition()", err.str(), 46);
544 return(*(mit->second));
549 FD_DRTI( "FunctionRegistry::Definition(): typeid " << typeid(rFunction).name());
553 std::stringstream err;
554 err << "Function not found: " << typeid(rFunction).name();
555 throw Exception( "FunctionRegistry::Definition()", err.str(), 46);
560 FD_DRTI( "FunctionRegistry::FunctionName(): typeid " << typeid(rFunction).name());
564 static const std::string empty( "");
589 rTw. WriteXmlComment( "===================================================");
590 rTw. WriteXmlComment( "===================================================");
592 rTw. WriteXmlComment( "===================================================");
593 rTw. WriteXmlComment( "===================================================");
595 tit->second-> Write(rTw);
615 FD_DREG( "LoadRegistry(" << rPath << ")");
617 std::string rtipath = rPath;
618 if(rtipath== "") rtipath= "./libfaudes.rti";
624 #ifndef FAUDES_MUTE_RTIAUTOLOAD
625 LoadRegisteredTypes();
630 #ifdef FAUDES_PLUGINS_RTILOAD
631 FAUDES_PLUGINS_RTILOAD;
636 #ifndef FAUDES_MUTE_RTIAUTOLOAD
637 LoadRegisteredFunctions();
645 #ifdef FAUDES_CHECKED
646 #ifndef FAUDES_MUTE_RTIAUTOLOAD
650 if(tit->second->PlugIn()!= "IODevice")
651 if(tit->second->Prototype()==NULL)
652 FD_WARN( "TypeRegistry: " << tit->second->Name() << " has no prototype");
657 if(fit->second->Prototype()==NULL)
658 FD_WARN( "FunctionRegistry: " << fit->second->Name() << " has no prototype");
663 FD_DREG( "LoadRegistry(" << rPath << "): done");
669 FD_DRTI( "SaveRegistry(" << rPath << ")");
libFAUDES 2.26g
--- 2015.08.17
--- c++ api documentaion by doxygen
|