cfl_registry.cpp
Go to the documentation of this file.
1 /** @file cfl_registry.cpp Runtime interface, registry for faudes types and functions */
2 
3 /* FAU Discrete Event Systems Library (libfaudes)
4 
5 Copyright (C) 2009 Ruediger Berndt
6 Copyright (C) 2009 Thomas Moor
7 
8 This library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Lesser General Public
10 License as published by the Free Software Foundation; either
11 version 2.1 of the License, or (at your option) any later version.
12 
13 This library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Lesser General Public License for more details.
17 
18 You should have received a copy of the GNU Lesser General Public
19 License along with this library; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
21 
22 
23 
24 #include "cfl_registry.h"
25 #include "corefaudes.h"
26 
27 // auto install types
28 #ifndef FAUDES_MUTE_RTIAUTOLOAD
29 #include <map>
30 #include <stack>
31 #include <set>
32 #include <vector>
33 #include <utility>
34 #include <limits>
35 #include "allplugins.h"
36 #include "rtiautoload.h"
37 #include "rtiautoload.cpp"
38 #endif
39 
40 
41 
42 namespace faudes{
43 
44 
45 
46 /*
47 ********************************************************************
48 ********************************************************************
49 ********************************************************************
50 
51 Implemantation of faudes TypeRegistry
52 
53 ********************************************************************
54 ********************************************************************
55 ********************************************************************
56 */
57 
58 // static members: ref to the only one instance
59 TypeRegistry* TypeRegistry::mpInstance = 0;
60 
61 // static member: access to singleton
63  // lazy initialization
64  if(!mpInstance){
65  FD_DREG("TypeRegistry(): Constrtuct singleton");
66  mpInstance = new TypeRegistry();
67  }
68  return(mpInstance);
69 }
70 
71 // clear except C++-autoregistered
73  FD_DREG("TypeRegistry::Clear(): begin with #" << Size());
74  // prepare: delete all typedefs contained in map, except fpr autoregistered
75  std::map<std::string, TypeDefinition*>::iterator mit;
76  for(mit = mNameToTypeDef.begin(); mit != mNameToTypeDef.end(); mit++){
77  if(mit->second != NULL)
78  if(!mit->second->AutoRegistered()){
79  delete mit->second;
80  mit->second = NULL;
81  }
82  if(mit->second != NULL)
83  if(mit->second->AutoRegistered()){
84  FD_DREG("TypeRegistry::Clear(): detect autoreg " << mit->second->Name());
85  }
86  }
87  // delete in NameToTypeDef
88  std::map<std::string, TypeDefinition*>::iterator dit;
89  for(mit = mNameToTypeDef.begin(); mit != mNameToTypeDef.end();){
90  dit=mit; mit++;
91  if(dit->second == NULL) mNameToTypeDef.erase(dit);
92  }
93  // fix Id map (this only works if autoregisreded typeids have no doublet faudes names)
94  mIdToTypeDef.clear();
95  for(mit = mNameToTypeDef.begin(); mit != mNameToTypeDef.end(); mit++){
96  TypeDefinition* ptdef=mit->second;
97  FD_DREG("TypeRegistry::Clear(): keeping " << ptdef->Name());
98  if(ptdef->Prototype())
99  if(mIdToTypeDef.find(typeid(*(ptdef->Prototype())).name())==
100  mIdToTypeDef.end())
101  mIdToTypeDef[typeid(*(ptdef->Prototype())).name()]=ptdef;
102  }
103 }
104 
105 // clear all.
107  FD_DREG("TypeRegistry::ClearAll()");
108  // delete all typedefs contained in map
109  std::map<std::string, TypeDefinition*>::iterator mit;
110  for(mit = mNameToTypeDef.begin(); mit != mNameToTypeDef.end(); mit++){
111  if(mit->second != NULL){
112  delete mit->second;
113  mit->second = NULL;
114  }
115  }
116  // delete maps
117  mNameToTypeDef.clear();
118  mIdToTypeDef.clear();
119 }
120 
121 // query number of entries
122 int TypeRegistry::Size() const{
123  return(mNameToTypeDef.size());
124 }
125 
126 // read access on type map
128  return(mNameToTypeDef.begin());
129 }
130 
131 // read access on type map
133  return(mNameToTypeDef.end());
134 }
135 
136 // insert new entry
138 #ifdef FAUDES_DEBUG_REGISTRY
139  if(pTypeDef->Prototype()) {
140  FD_DREG("TypeRegistry::Insert(): definition for " << pTypeDef->Name());
141  } else {
142  //FD_DREG("TypeRegistry::Insert(): fake entry for " << pTypeDef->Name());
143  }
144 #endif
145  // test existence that match: ignore
146  if(Exists(pTypeDef->Name())){
147  const TypeDefinition* otdef = Definitionp(pTypeDef->Name());
148  if(typeid(*(pTypeDef->Prototype())).name() == typeid(*(otdef->Prototype())).name()) {
149  FD_DREG("TypeRegistry::Insert(): ignore doublet " << pTypeDef->Name());
150  return;
151  }
152  }
153  // test existence that differ: error
154  if(Exists(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);
158  }
159  // test for name
160  if(pTypeDef->Name()=="") {
161  std::stringstream err;
162  err << "Cannot have empty name"<< std::endl;
163  throw Exception("TypeRegistry::Insert()", err.str(), 46);
164  };
165  // record in main map
166  mNameToTypeDef[pTypeDef->Name()]=pTypeDef;
167  // record in id map (first entry wins)
168  if(pTypeDef->Prototype())
169  if(mIdToTypeDef.find(typeid(*(pTypeDef->Prototype())).name())==
170  mIdToTypeDef.end())
171  mIdToTypeDef[typeid(*(pTypeDef->Prototype())).name()]=pTypeDef;
172 }
173 
174 
175 // scan token stream for type definitions
177  FD_DREG("TypeRegistry::MergeDocumentation(): using " << rTr.FileName());
178  // scan file
179  Token token;
180  while(rTr.Peek(token)) {
181  // test for TypeDefinition with name
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; }
185  // found type def in file, extract ftype
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);
190  // locate type def in map
191  Iterator tit = mNameToTypeDef.find(ftype);
192  // case 1: type exists (from LoadRegistry or c++-Autoregister): add documentaion
193  if(tit!=mNameToTypeDef.end()) {
194  tit->second->MergeDocumentation(rTr);
195  continue;
196  }
197  // case 2: type does not exist (e.g. with ref2html): insert fake entry
198  TypeDefinition* tdef = new TypeDefinition(ftype);
199  tdef->MergeDocumentation(rTr);
200  Insert(tdef);
201  }
202 }
203 
204 // scan file for type definitions
205 void TypeRegistry::MergeDocumentation(const std::string& rFileName) {
206  TokenReader tr(rFileName);
207  MergeDocumentation(tr);
208 }
209 
210 
211 // set XML element tag
212 void TypeRegistry::XElementTag(const std::string& rTypeName, const std::string& rTag) {
213  Iterator mit=mNameToTypeDef.find(rTypeName);
214  if(mit == End()) return;
215  mit->second->XElementTag(rTag);
216 }
217 
218 // get XML element tag
219 const std::string& TypeRegistry::XElementTag(const std::string& rTypeName) const {
220  Iterator mit=mNameToTypeDef.find(rTypeName);
221  static std::string estr="";
222  if(mit == End()) return estr;
223  return mit->second->XElementTag();
224 }
225 
226 
227 // set auto-register flag
228 void TypeRegistry::AutoRegistered(const std::string& rTypeName, bool flag) {
229  Iterator mit=mNameToTypeDef.find(rTypeName);
230  if(mit == End()) {
231  FD_DREG("TypeRegistry::AutoRegistered(...): cannot access definition for faudes type " << rTypeName);
232  return;
233  }
234  mit->second->AutoRegistered(flag);
235 }
236 
237 // get auto-register flag
238 bool TypeRegistry::AutoRegistered(const std::string& rTypeName) const {
239  Iterator mit=mNameToTypeDef.find(rTypeName);
240  if(mit == End()) return false;
241  return mit->second->AutoRegistered();
242 }
243 
244 
245 // construct faudes object by typename
246 Type* TypeRegistry::NewObject(const std::string& rName) const{
247  FD_DRTI("TypeRegistry::NewObject(\"" << rName << "\")");
248  Iterator mit=mNameToTypeDef.find(rName);
249  if(mit == End()) {
250  std::stringstream err;
251  err << "Unknown Type " << rName << std::endl;
252  throw Exception("TypeRegistry::NewObject()", err.str(), 47);
253  }
254  Type* res=mit->second->NewObject();
255  if(!res) {
256  std::stringstream err;
257  err << "Failed to instatiate new " << rName << std::endl;
258  throw Exception("TypeRegistry::NewObject()", err.str(), 47);
259  }
260  return res;
261 }
262 
263 // construct faudes object by typed reference
264 Type* TypeRegistry::NewObject(const Type& rType) const{
265  FD_DRTI("TypeRegistry::NewObject(prototype): typeid " << typeid(rType).name());
266  Iterator mit;
267  mit=mIdToTypeDef.find(typeid(rType).name());
268  if(mit == mIdToTypeDef.end()) {
269  std::stringstream err;
270  err << "Unknown type by reference" << std::endl;
271  throw Exception("TypeRegistry::NewObject()", err.str(), 47);
272  }
273  return(rType.New());
274 }
275 
276 // access type definition by type name
277 const TypeDefinition& TypeRegistry::Definition(const std::string& rName) const{
278  FD_DRTI("TypeRegistry::Definition( " << rName << " )");
279  Iterator mit=mNameToTypeDef.find(rName);
280  if(mit == End()) {
281  std::stringstream err;
282  err << "Type not found: \"" << rName << "\"";
283  throw Exception("TypeRegistry::Definition()", err.str(), 46);
284  }
285  return(*(mit->second));
286 }
287 
288 // access type definition by typed reference
289 const TypeDefinition& TypeRegistry::Definition(const Type& rType) const{
290  FD_DRTI("TypeRegistry::Definition(): typeid " << typeid(rType).name());
291  Iterator mit;
292  mit=mIdToTypeDef.find(typeid(rType).name());
293  if(mit!=mIdToTypeDef.end()) return *(mit->second);
294  std::stringstream err;
295  err << "Type not found: " << typeid(rType).name();
296  throw Exception("TypeRegistry::Definition()", err.str(), 46);
297 }
298 
299 // access type definition by type name
300 const TypeDefinition* TypeRegistry::Definitionp(const std::string& rName) const{
301  FD_DRTI("TypeRegistry::Definitionp( " << rName << " )");
302  Iterator mit=mNameToTypeDef.find(rName);
303  if(mit == End()) return NULL;
304  return(mit->second);
305 }
306 
307 // access type definition by typed reference
308 const TypeDefinition* TypeRegistry::Definitionp(const Type& rType) const{
309  FD_DRTI("TypeRegistry::Definitionp(): typeid " << typeid(rType).name());
310  Iterator mit;
311  mit=mIdToTypeDef.find(typeid(rType).name());
312  if(mit==mIdToTypeDef.end()) return NULL;
313  return(mit->second);
314 }
315 
316 // access prototype by type name
317 const Type* TypeRegistry::Prototype(const std::string& rName) const{
318  FD_DRTI("TypeRegistry::Prototype( " << rName << " )");
319  Iterator mit=mNameToTypeDef.find(rName);
320  if(mit == End()) return 0;
321  return(mit->second->Prototype());
322 }
323 
324 // access type definition by typed reference
325 const std::string& TypeRegistry::TypeName(const Type& rType) const{
326  FD_DRTI("TypeRegistry::TypeName(): typeid " << typeid(rType).name());
327  Iterator mit;
328  mit=mIdToTypeDef.find(typeid(rType).name());
329  if(mit!=mIdToTypeDef.end()) return mit->second->Name();
330  static std::string empty("");
331  return empty;
332 }
333 
334 // test type compatibility
335 bool TypeRegistry::TypeTest(const std::string& rTypeName, const Type& rObject) const {
336  FD_DRTI("TypeRegistry::TypeTest(): typeid " << typeid(rObject).name());
337  Iterator mit=mNameToTypeDef.find(rTypeName);
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 );
343 }
344 
345 // test existence by type name
346 bool TypeRegistry::Exists(const std::string& rName) const{
347  return mNameToTypeDef.find(rName) != End();
348 }
349 
350 // test existsnce by type name
351 bool TypeRegistry::Exists(const Type& rType) const{
352  return mIdToTypeDef.find(typeid(rType).name()) != mIdToTypeDef.end();
353 }
354 
355 
356 // token write (informative/debugging)
357 void TypeRegistry::DoWrite(TokenWriter& rTw, const std::string& rLabel, const Type* pContext) const {
358  FD_DRTI("TypeRegistry::DoWrite(): file " << rTw.FileName());
359  // ignore label and context
360  (void) rLabel;
361  (void) pContext;
362  // doit
363  Iterator tit;
364  for(tit=Begin();tit!=End();tit++) {
365  // write type definition
366  rTw.WriteXmlComment("===================================================");
367  rTw.WriteXmlComment("===================================================");
368  rTw.WriteXmlComment("Faudes Type " + tit->second->Name());
369  rTw.WriteXmlComment("===================================================");
370  rTw.WriteXmlComment("===================================================");
371  rTw << "\n";
372  tit->second->Write(rTw);
373  rTw << "\n" << "\n";
374  }
375 }
376 
377 
378 /*
379 ********************************************************************
380 ********************************************************************
381 ********************************************************************
382 
383 Implemantation of faudes FunctionRegistry
384 
385 ********************************************************************
386 ********************************************************************
387 ********************************************************************
388 */
389 
390 // static members: ref to the only one instnace
392 
393 // static member: access to signleton
395  // lazy initialization
396  if(!mpInstance){
397  FD_DREG("FunctionRegistry(): Construct singleton");
399  }
400  return(mpInstance);
401 }
402 
403 // clear all
405  FD_DREG("FunctionRegistry::Clear()");
406  // delete all functiondefs contained in map
407  std::map<std::string, FunctionDefinition*>::iterator mit;
408  for(mit = mNameToFunctionDef.begin(); mit != mNameToFunctionDef.end(); mit++){
409  if(mit->second != NULL) {
410  FD_DREG("FunctionRegistry::Clear: removing " << mit->second->Name());
411  delete mit->second;
412  mit->second = NULL;
413  }
414  }
415  // delete maps
416  mNameToFunctionDef.clear();
417  mIdToFunctionDef.clear();
418 }
419 
420 // query number of entries
422  return(mNameToFunctionDef.size());
423 }
424 
425 // read access on function map
427  return(mNameToFunctionDef.begin());
428 }
429 
430 // read access on function map
432  return(mNameToFunctionDef.end());
433 }
434 
435 // insert new entry
437 #ifdef FAUDES_DEBUG_REGISTRY
438  if(pFunctionDef->Prototype()) {
439  FD_DREG("FunctionRegistry::Insert(): definition for " << pFunctionDef->Name());
440  } else {
441  //FD_DREG("FunctionRegistry::Insert(): fake entry for " << pFunctionDef->Name());
442  }
443 #endif
444  // test existence
445  if(Exists(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);
449  }
450  // test for name
451  if(pFunctionDef->Name()=="") {
452  std::stringstream err;
453  err << "Cannot have empty name"<< std::endl;
454  throw Exception("FunctionRegistry::Insert()", err.str(), 46);
455  };
456  // record in map
457  mNameToFunctionDef[pFunctionDef->Name()]=pFunctionDef;
458  // record in id map
459  if(pFunctionDef->Prototype())
460  mIdToFunctionDef[typeid(*(pFunctionDef->Prototype())).name()]=pFunctionDef;
461 }
462 
463 
464 // scan token stream for function definitions
466  FD_DREG("FunctionRegistry::MergeDocumentation(): using " << rTr.FileName());
467  // scan file
468  Token token;
469  while(rTr.Peek(token)) {
470  // test for FunctionDefinition with name
471  // note: we intentionally accept LuaFunctionDefinitions for RTI documentation
472  if(!token.IsBegin())
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; }
478  // found function def in file, extract ftype
479  std::string ffunction=token.AttributeStringValue("name");
480  size_t pos=ffunction.find("::");
481  if(pos!=std::string::npos) ffunction=ffunction.substr(pos+2);
482  // locate functiondef in map
483  Iterator fit = mNameToFunctionDef.find(ffunction);
484  // case 1: function exists (from LoadRegistry or c++-Autoregister): add documentaion
485  if(fit!=mNameToFunctionDef.end()) {
486  fit->second->MergeDocumentation(rTr);
487  continue;
488  }
489  // case 2: function does not exist (e.g. with ref2html): insert fake entry
490  FunctionDefinition* fdef = new FunctionDefinition(ffunction);
491  fdef->MergeDocumentation(rTr);
492  Insert(fdef);
493  }
494 }
495 
496 
497 // scan file for function definitions
498 void FunctionRegistry::MergeDocumentation(const std::string& rFileName) {
499  TokenReader tr(rFileName);
500  MergeDocumentation(tr);
501 }
502 
503 
504 // construct faudes object by functionname
505 Function* FunctionRegistry::NewFunction(const std::string& rName) const{
506  FD_DRTI("FunctionRegistry::NewFunction(\"" << rName << "\")");
507  Iterator mit=mNameToFunctionDef.find(rName);
508  if(mit == End()) {
509  std::stringstream err;
510  err << "Unknown function " << rName << std::endl;
511  throw Exception("FunctionRegistry::NewFunction()", err.str(), 47);
512  }
513  Function* res=mit->second->NewFunction();
514  if(!res) {
515  std::stringstream err;
516  err << "Failed to instatiate new " << rName << std::endl;
517  throw Exception("FunctionRegistry::NewFunction()", err.str(), 47);
518  }
519  return res;
520 }
521 
522 // construct faudes object by function reference
524  FD_DRTI("FunctionRegistry::NewFunction(prototype): typeid " << typeid(rFunction).name());
525  Iterator mit;
526  mit=mIdToFunctionDef.find(typeid(rFunction).name());
527  if(mit == mIdToFunctionDef.end()) {
528  std::stringstream err;
529  err << "Unknown function by reference" << std::endl;
530  throw Exception("FunctionRegistry::NewFunction()", err.str(), 47);
531  }
532  return(rFunction.New());
533 }
534 
535 // access function definition by function name
536 const FunctionDefinition& FunctionRegistry::Definition(const std::string& rName) const{
537  FD_DRTI("FunctionRegistry::Definition( " << rName << " )");
538  Iterator mit=mNameToFunctionDef.find(rName);
539  if(mit == End()) {
540  std::stringstream err;
541  err << "Function not found: " << rName;
542  throw Exception("FunctionRegistry::Definition()", err.str(), 46);
543  }
544  return(*(mit->second));
545 }
546 
547 // access function definition by functiond reference
549  FD_DRTI("FunctionRegistry::Definition(): typeid " << typeid(rFunction).name());
550  Iterator mit;
551  mit=mIdToFunctionDef.find(typeid(rFunction).name());
552  if(mit!=mIdToFunctionDef.end()) return *(mit->second);
553  std::stringstream err;
554  err << "Function not found: " << typeid(rFunction).name();
555  throw Exception("FunctionRegistry::Definition()", err.str(), 46);
556 }
557 
558 // access function definition by typed reference
559 const std::string& FunctionRegistry::FunctionName(const Function& rFunction) const{
560  FD_DRTI("FunctionRegistry::FunctionName(): typeid " << typeid(rFunction).name());
561  Iterator mit;
562  mit=mIdToFunctionDef.find(typeid(rFunction).name());
563  if(mit!=mIdToFunctionDef.end()) return mit->second->Name();
564  static const std::string empty("");
565  return empty;
566 }
567 
568 // test existence by function name
569 bool FunctionRegistry::Exists(const std::string& rName) const{
570  return mNameToFunctionDef.find(rName) != End();
571 }
572 
573 // test existsnce by function
574 bool FunctionRegistry::Exists(const Function& rFunction) const{
575  return mIdToFunctionDef.find(typeid(rFunction).name()) != mIdToFunctionDef.end();
576 }
577 
578 
579 // token write (informative/debugging)
580 void FunctionRegistry::DoWrite(TokenWriter& rTw, const std::string& rLabel, const Type* pContext) const {
581  FD_DREG("FunctionRegistry::DoWrite(): file " << rTw.FileName());
582  // ignore label and context
583  (void) rLabel;
584  (void) pContext;
585  // doit
586  Iterator tit;
587  for(tit=Begin();tit!=End();tit++) {
588  // write function definition
589  rTw.WriteXmlComment("===================================================");
590  rTw.WriteXmlComment("===================================================");
591  rTw.WriteXmlComment("Faudes Function " + tit->second->Name());
592  rTw.WriteXmlComment("===================================================");
593  rTw.WriteXmlComment("===================================================");
594  rTw << "\n";
595  tit->second->Write(rTw);
596  rTw << "\n" << "\n";
597  }
598 }
599 
600 
601 /*
602 ********************************************************************
603 ********************************************************************
604 ********************************************************************
605 
606 Implemantation of LoadRegistry
607 
608 ********************************************************************
609 ********************************************************************
610 ********************************************************************
611 */
612 
613 // load from file
614 void LoadRegistry(const std::string& rPath) {
615  FD_DREG("LoadRegistry(" << rPath << ")");
616  // default path
617  std::string rtipath = rPath;
618  if(rtipath=="") rtipath="./libfaudes.rti"; // todo: plattform/configure
619  // clear
620  TypeRegistry::G()->Clear(); // note: we do not clear "c++-autoregistered" types
622 
623  // auto install types extracted from rti file
624 #ifndef FAUDES_MUTE_RTIAUTOLOAD
625  LoadRegisteredTypes(); // note: this does not load "c++-autoregistered" types
626 #endif
627 
628  // allow build system load registry programmatic contributions defined in plugins
629  // (this is currently not used by any plug-in)
630 #ifdef FAUDES_PLUGINS_RTILOAD
631  FAUDES_PLUGINS_RTILOAD;
632 #endif
633 
634  // auto install functions extracted from rti file
635  // (this is currently not used by any plug-in)
636 #ifndef FAUDES_MUTE_RTIAUTOLOAD
637  LoadRegisteredFunctions();
638 #endif
639 
640  // merge documentation
643 
644  // test and report status
645 #ifdef FAUDES_CHECKED
646 #ifndef FAUDES_MUTE_RTIAUTOLOAD
648  for(tit=TypeRegistry::G()->Begin(); tit!=TypeRegistry::G()->End(); tit++) {
649  // should have prototype
650  if(tit->second->PlugIn()!="IODevice")
651  if(tit->second->Prototype()==NULL)
652  FD_WARN("TypeRegistry: " << tit->second->Name() << " has no prototype");
653  }
655  for(fit=FunctionRegistry::G()->Begin(); fit!=FunctionRegistry::G()->End(); fit++) {
656  // should have prototype
657  if(fit->second->Prototype()==NULL)
658  FD_WARN("FunctionRegistry: " << fit->second->Name() << " has no prototype");
659  }
660 #endif
661 #endif
662 
663  FD_DREG("LoadRegistry(" << rPath << "): done");
664 }
665 
666 
667 // save to file or std out
668 void SaveRegistry(const std::string& rPath) {
669  FD_DRTI("SaveRegistry(" << rPath << ")");
670  // have a tokenwriter
671  TokenWriter* ptw;
672  if(rPath=="") {
673  ptw = new TokenWriter(TokenWriter::Stdout);
674  } else {
675  ptw = new TokenWriter(rPath,"Registry");
676  }
677  // do the write
678  ptw->WriteBegin("Registry");
679  TypeRegistry::G()->Write(*ptw);
680  FunctionRegistry::G()->Write(*ptw);
681  ptw->WriteEnd("Registry");
682  // dispose
683  delete ptw;
684 }
685 
686 
687 // clear all
688 void ClearRegistry(void) {
689  FD_DRTI("ClearRegistry()");
690  // clear
693 }
694 
695 // conveience access to singleton
696 Type* NewFaudesObject(const std::string& rTypeName) { return TypeRegistry::G()->NewObject(rTypeName);}
697 Function* NewFaudesFunction(const std::string& rFunctName) { return FunctionRegistry::G()->NewFunction(rFunctName);}
698 const std::string& FaudesTypeName(const Type& rObject) { return TypeRegistry::G()->TypeName(rObject);}
699 bool FaudesTypeTest(const std::string& rTypeName, const Type& rObject) { return TypeRegistry::G()->TypeTest(rTypeName,rObject);}
700 const std::string& FaudesFunctionName(const Function& rObject) { return FunctionRegistry::G()->FunctionName(rObject);}
701 
702 
703 } // namespace

libFAUDES 2.26g --- 2015.08.17 --- c++ api documentaion by doxygen