cfl_types.cpp
Go to the documentation of this file.
1 /** @file cfl_types.cpp Runtime interface, faudes types */
2 
3 /* FAU Discrete Event Systems Library (libfaudes)
4 
5 Copyright (C) 2009 Ruediger Berndt
6 Copyright (C) 2010 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 #include "cfl_types.h"
24 #include "cfl_registry.h"
25 
26 namespace faudes{
27 
28 /*
29 ********************************************************************
30 ********************************************************************
31 ********************************************************************
32 
33 implemantation of faudes Type
34 
35 ********************************************************************
36 ********************************************************************
37 ********************************************************************
38 */
39 
40 // statics
41 std::string Type::msStringVoid("Void");
42 std::string Type::msStringEmpty("");
43 
44 // constructor
45 Type::Type(void) {}
46 
47 // copy constructor
48 Type::Type(const Type& rType) {(void) rType;}
49 
50 // destructor
51 Type::~Type(void) {}
52 
53 // pointer constructor
54 Type* Type::New(void) const {
55  FD_WARN("Type(" << this << ")::New(): not reimplemented for " << typeid(*this).name());
56  return new Type();
57 }
58 
59 // pointer copy constructor
60 Type* Type::Copy(void) const {
61  FD_WARN("Type(" << this << ")::Copy(): not reimplemented for " << typeid(*this).name());
62  return new Type(*this);
63 }
64 
65 // cast
66 const Type* Type::Cast(const Type* pOther) const {
67  FD_WARN("Type(" << this << ")::Cast(" << pOther << "): not reimplemented for " << typeid(*this).name());
68  return pOther;
69 }
70 
71 // Clear()
72 void Type::Clear(void) {
73  FD_DC("Type::Clear(): not re-implemented in " << typeid(*this).name());
74 }
75 
76 // assign
77 Type& Type::Assign(const Type& rSource) {
78  FD_DC("Type(" << this << ")::Assign(" << &rSource << ")");
79  Clear();
80  return *this;
81 }
82 
83 // equality (relaxed)
84 bool Type::Equal(const Type& rOther) const {
85  return true;
86 }
87 
88 // equality (strict)
89 bool Type::operator==(const Type& rOther) const {
90  return DoEqual(rOther);
91 }
92 
93 // equality
94 bool Type::operator!=(const Type& rOther) const {
95  return !DoEqual(rOther);
96 }
97 
98 // assign
99 Type& Type::operator=(const Type& rSource) {
100  FD_DC("Type(" << this << ")::AssignementOperator(" << &rSource << ")");
101  Clear();
102  DoAssign(rSource);
103  return *this;
104 }
105 
106 // assign
107 void Type::DoAssign(const Type& rSource) {
108  FD_DC("Type(" << this << ")::DoAssign(" << &rSource << ")");
109 }
110 
111 // equality
112 bool Type::DoEqual(const Type& rOther) const {
113  //typeid(*this)==typeid(rOther); TM 2025
114  return true;
115 }
116 
117 // Name(rName)
118 void Type::Name(const std::string& rName) {
119  (void) rName;
120 }
121 
122 // Name()
123 const std::string& Type::Name(void) const {
124  return msStringEmpty;
125 }
126 
127 // TypeDefinitionp()
129  return TypeRegistry::G()->Definitionp(*this);
130 }
131 
132 // TypeName()
133 const std::string& Type::TypeName(void) const {
134  const TypeDefinition* fdp=TypeDefinitionp();
135  if(!fdp) return msStringEmpty;
136  return fdp->Name();
137 }
138 
139 // Write(context)
140 void Type::Write(const Type* pContext) const {
142  DoWrite(tw,"",pContext);
143 }
144 
145 // Write(rFileName, label, context, openmode)
146 void Type::Write(const std::string& rFileName, const std::string& rLabel,
147  const Type* pContext, std::ios::openmode openmode) const {
148  try {
149  TokenWriter tw(rFileName, openmode);
150  DoWrite(tw, rLabel, pContext);
151  }
152  catch(std::ios::failure&) {
153  std::stringstream errstr;
154  errstr << "Exception opening/writing file \"" << rFileName << "\"";
155  throw Exception("Type::Write", errstr.str(), 2);
156  }
157 }
158 
159 // Write(rFileName, openmode)
160 void Type::Write(const std::string& rFileName, std::ios::openmode openmode) const {
161  Write(rFileName,"",0,openmode);
162 }
163 
164 // Write(tw,label,context)
165 void Type::Write(TokenWriter& rTw, const std::string& rLabel, const Type* pContext) const {
166  DoWrite(rTw,rLabel,pContext);
167 }
168 
169 // ToString(label, context)
170 std::string Type::ToString(const std::string& rLabel, const Type* pContext) const {
172  tw.Endl(false);
173  DoWrite(tw,rLabel,pContext);
174  return tw.Str();
175 }
176 
177 // ToSText()
178 std::string Type::ToSText(void) const {
180  tw.Endl(true);
181  DoSWrite(tw);
182  return tw.Str();
183 }
184 
185 // ToString(label, context)
186 std::string Type::ToText(const std::string& rLabel, const Type* pContext) const {
188  tw.Endl(true);
189  DoWrite(tw,rLabel,pContext);
190  return tw.Str();
191 }
192 
193 // XWrite(context)
194 void Type::XWrite(const Type* pContext) const {
195  FD_DC("Type(" << this << ")::XWrite(): for " << typeid(*this).name());
197  DoXWrite(tw,"",pContext);
198 }
199 
200 // XWrite(rFileName, label, context)
201 void Type::XWrite(const std::string& rFileName, const std::string& rLabel, const Type* pContext) const {
202  std::string ftype=TypeName();
203  if(ftype=="") {
204  std::stringstream errstr;
205  errstr << "Cannot write unregistered faudes-type object \"" << typeid(*this).name() << "\"";
206  throw Exception("Type::XWrite", errstr.str(), 2);
207  }
208  try {
209  TokenWriter tw(rFileName,ftype);
210  XWrite(tw, rLabel, pContext);
211  }
212  catch(std::ios::failure&) {
213  std::stringstream errstr;
214  errstr << "Exception opening/writing file \"" << rFileName << "\"";
215  throw Exception("Type::XWrite", errstr.str(), 2);
216  }
217 }
218 
219 // XWrite(tw,label,context)
220 void Type::XWrite(TokenWriter& rTw, const std::string& rLabel, const Type* pContext) const {
221  FD_DC("Type(" << this << ")::XWrrite(): for " << typeid(*this).name());
222  DoXWrite(rTw,rLabel,pContext);
223 }
224 
225 // DWrite(context)
226 void Type::DWrite(const Type* pContext) const {
228  DoDWrite(tw,"",pContext);
229 }
230 
231 // DWrite(rFileName, label, context, openmode)
232 void Type::DWrite(const std::string& rFileName, const std::string& rLabel,
233  const Type* pContext, std::ios::openmode openmode) const {
234  try {
235  TokenWriter tw(rFileName, openmode);
236  DoDWrite(tw, rLabel, pContext);
237  }
238  catch(std::ios::failure&) {
239  std::stringstream errstr;
240  errstr << "Exception opening/writing file \"" << rFileName << "\"";
241  throw Exception("Type::DWrite", errstr.str(), 2);
242  }
243 }
244 
245 // DWrite(tw,label,context)
246 void Type::DWrite(TokenWriter& rTw, const std::string& rLabel, const Type* pContext) const {
247  DoDWrite(rTw,rLabel,pContext);
248 }
249 
250 // SWrite()
251 void Type::SWrite(void) const {
253  DoSWrite(tw);
254 }
255 
256 // SWrite(tw)
257 void Type::SWrite(TokenWriter& rTw) const {
258  DoSWrite(rTw);
259 }
260 
261 // Read(rFilename, rLabel,context)
262 void Type::Read(const std::string& rFilename, const std::string& rLabel, const Type* pContext) {
263  Clear();
264  TokenReader tr(rFilename);
265  if(rLabel!="") tr.SeekBegin(rLabel);
266  DoRead(tr,rLabel,pContext);
267 }
268 
269 // Read(rTr, rLabel, context)
270 void Type::Read(TokenReader& rTr, const std::string& rLabel, const Type* pContext) {
271  Clear();
272  DoRead(rTr,rLabel,pContext);
273 }
274 
275 // FromString(rString, rLabel, context)
276 void Type::FromString(const std::string& rString, const std::string& rLabel, const Type* pContext) {
277  Clear();
278  TokenReader tr(TokenReader::String,rString);
279  DoRead(tr,rLabel,pContext);
280 }
281 
282 //DoWrite(rTr,rLabel,pContext)
283 void Type::DoWrite(TokenWriter& rTw, const std::string& rLabel, const Type* pContext) const {
284  (void) rTw; (void) rLabel; (void) pContext;
285  FD_DC("Type::DoWrite(): not re-implemented in " << typeid(*this).name());
286 }
287 
288 //DoXWrite(rTr,rLabel,pContext)
289 void Type::DoXWrite(TokenWriter& rTw, const std::string& rLabel, const Type* pContext) const {
290  DoWrite(rTw, rLabel, pContext);
291 }
292 
293 //DoDWrite(rTr,rLabel,pContext)
294 void Type::DoDWrite(TokenWriter& rTw, const std::string& rLabel, const Type* pContext) const {
295  FD_DC("Type::DoDWrite(): not re-implemented in " << typeid(*this).name() << ", using DoDWrite instead");
296  DoWrite(rTw,rLabel,pContext);
297 }
298 
299 //DoSWrite(rTr,rLabel,pContext)
300 void Type::DoSWrite(TokenWriter& rTw) const {
301  FD_DC("Type::DoSWrite(): not re-implemented in " << typeid(*this).name());
302  rTw.WriteComment("");
303  rTw.WriteComment(" Statistics for " + Name());
304  rTw.WriteComment("");
305 }
306 
307 //DoRead(rTr,rLabel,pContext)
308 void Type::DoRead(TokenReader& rTr, const std::string& rLabel, const Type* pContext) {
309  (void) rLabel; (void) pContext; (void) rTr;
310  FD_DC("Type::DoRead(): not re-implemented in " << typeid(*this).name());
311 }
312 
313 
314 
315 // configure begin token
316 Token Type::XBeginTag(const std::string& rLabel,const std::string& rFallbackLabel) const {
317  // provided
318  std::string label=rLabel;
319  std::string ftype=TypeName();
320  // fallback label
321  if(label=="") label=ftype;
322  if(label=="") label=rFallbackLabel;
323  Token btag;
324  btag.SetBegin(label);
325  if(Name()!=label && Name()!="") btag.InsAttributeString("name",Name());
326  if(ftype!=label && ftype!="") btag.InsAttributeString("ftype",ftype);
327  // done
328  return btag;
329 }
330 
331 
332 
333 /*
334 ********************************************************************
335 ********************************************************************
336 ********************************************************************
337 
338 Implementation of class Documentation
339 
340 ********************************************************************
341 ********************************************************************
342 ********************************************************************
343 */
344 
345 // faudes type (cannot do autoregister)
351 
352 // construct
354  mAutoRegistered=false;
355  mApplicationRegistered=false;
356 }
357 
358 // construct
360  DoAssign(rOther);
361 }
362 
363 // std faudes type
365  // assign my members
366  mName=rSrc.mName;
367  mPlugIn=rSrc.mPlugIn;
368  mHtmlDoc=rSrc.mHtmlDoc;
369  mTextDoc=rSrc.mTextDoc;
370  mKeywords=rSrc.mKeywords;
371 }
372 
373 // std faudes type
374 bool Documentation::DoEqual(const Documentation& rOther) const {
375  // test my members
376  if(mName!=rOther.mName) return false;
377  if(mPlugIn!=rOther.mPlugIn) return false;
378  if(mHtmlDoc!=rOther.mHtmlDoc) return false;
379  if(mTextDoc!=rOther.mTextDoc) return false;
380  if(mKeywords!=rOther.mKeywords) return false;
381  return true;
382 }
383 
384 // clear all
386  FD_DRTI("Documentation::Clear()");
387  mName="";
388  mPlugIn="CoreFaudes";
389  mHtmlDoc="";
390  mTextDoc="";
392  mAutoRegistered=false;
394 }
395 
396 // read access members
397 const std::string& Documentation::Name(void) const{ return mName; }
398 const std::string& Documentation::PlugIn(void) const{ return mPlugIn; }
399 const std::string& Documentation::CType(void) const{ return mCType; }
400 const std::string& Documentation::TextDoc() const{ return mTextDoc; }
401 const std::string& Documentation::HtmlDoc() const{ return mHtmlDoc; }
402 const std::string& Documentation::Keywords() const{ return mKeywords; }
405 
406 // write access members
407 void Documentation::Name(const std::string& name){mName = name; }
408 void Documentation::PlugIn(const std::string& plugin){mPlugIn = plugin; }
409 void Documentation::CType(const std::string& name){mCType = name; }
410 void Documentation::TextDoc(const std::string& textdoc){mTextDoc = textdoc;}
411 void Documentation::HtmlDoc(const std::string& fname){mHtmlDoc = fname;}
414 
415 // write access keyword
416 void Documentation::AddKeyword(const std::string& rKeyword){
417  if(mKeywords.empty()){
418  mKeywords = rKeyword;
419  } else{
420  mKeywords.append(1, mDelim);
421  mKeywords.append(rKeyword);
422  }
423 }
424 
425 // regex match keywords (todo)
426 std::string Documentation::MatchKeyword(const std::string& rPattern) const{
427  FD_DRTI("Documentation::MatchKeyword(" << rPattern << ")");
428  // be case insensitive (inefficient)
429  std::string keys = mKeywords;
430  std::transform(keys.begin(), keys.end(), keys.begin(), tolower);
431  std::string match = rPattern;
432  std::transform(match.begin(), match.end(), match.begin(), tolower);
433  // find match
434  std::string res="";
435  std::size_t posk=keys.find(match);
436  if(posk==std::string::npos) return res;
437  // find delimiters
438  std::size_t posa=0;
439  std::size_t posb=keys.length();
440  while(true) {
441  posb=keys.find(mDelim,posa);
442  if(posb==std::string::npos) posb=mKeywords.length();
443  if(posb>posk) break;
444  posa=posb+1;
445  };
446  // return original case match
447  FD_DRTI("Documentation::MatchKeyword(" << rPattern << "): " << mKeywords.substr(posa,posb-posa));
448  return mKeywords.substr(posa,posb-posa);
449 }
450 
451 
452 // positional keyword
453 std::string Documentation::KeywordAt(int pos) const{
454  FD_DRTI("Documentation::KeywordAt(" << pos << ")");
455  // default result
456  std::string res="";
457  // find delimiter
458  std::size_t posa=0;
459  std::size_t posb=mKeywords.length();
460  while(pos>0) {
461  if(posa>=mKeywords.length()) return res;
462  posb=mKeywords.find(mDelim,posa);
463  if(posb==std::string::npos) return res;
464  posa=posb+1;
465  pos--;
466  };
467  // default result
468  res=mKeywords.substr(posa);
469  // find next delimiter
470  posb=res.find(mDelim);
471  if(posb==std::string::npos) return res;
472  res=res.substr(0,posb);
473  return res;
474 }
475 
476 // keyword
478  int cnt=0;
479  // find delimiter
480  std::size_t pos=0;
481  while(pos<mKeywords.length()) {
482  cnt++;
483  pos=mKeywords.find(mDelim,pos);
484  if(pos==std::string::npos) break;
485  pos++;
486  };
487  return cnt;
488 }
489 
490 
491 // merge with docu from token io
493  FD_DRTI("Documentation::MergeDocumentation(): for " << mName);
494  // get first token to test type definition
495  Token token;
496  rTr.Peek(token);
497  if(!token.IsBegin()) return;
498  std::string label=token.StringValue();
499  // get ftype and test for match
500  std::string ftype=token.AttributeStringValue("name");
501  size_t pos=ftype.find("::");
502  if(pos!=std::string::npos) ftype=ftype.substr(pos+2);
503  // match?
504  if( (mName!=ftype && mName!="") || (ftype=="")) {
505  std::stringstream errstr;
506  errstr << "Documentation mismatch in file \"" << rTr.FileName() << "\" : " << mName << "!=" << ftype;
507  throw Exception("Documentation::MergeDocumentation", errstr.str(), 48);
508  };
509  // do read
510  DoRead(rTr,label);
511 }
512 
513 // token io
514 void Documentation::DoRead(TokenReader& rTr, const std::string& rLabel, const Type* pContext) {
515  FD_DRTI("Documentation::DoRead(): file " << rTr.FileName());
516  // ignore
517  (void) pContext;
518  // figure my section
519  std::string label = rLabel;
520  if(label=="") label="Documentation";
521  // get first token for ftype and ctype
522  Token token;
523  rTr.ReadBegin(label,token);
524 
525  // sense and digest pre 2.16b format
526  if(!token.ExistsAttributeString("name")) {
527  Token ptoken;
528  rTr.Peek(ptoken);
529  mName=ptoken.StringValue();
530  size_t pos=mName.find("::");
531  if(pos!=std::string::npos) mName=mName.substr(pos+2);
532  mPlugIn=ptoken.StringValue();
533  pos=mPlugIn.find("::");
534  if(pos!=std::string::npos) mPlugIn=mPlugIn.substr(0,pos);
535  else mPlugIn = "CoreFaudes";
536  DoReadCore(rTr);
537  rTr.ReadEnd(label);
538  return;
539  } // end pre 2.16b format
540 
541  // get ftype
542  mName=token.AttributeStringValue("name");
543  size_t pos=mName.find("::");
544  if(pos!=std::string::npos) mName=mName.substr(pos+2);
545  // get plugin
546  mPlugIn=token.AttributeStringValue("name");
547  pos=mPlugIn.find("::");
548  if(pos!=std::string::npos) mPlugIn=mPlugIn.substr(0,pos);
549  else mPlugIn = "CoreFaudes";
550  // get ctype
551  mCType=token.AttributeStringValue("ctype");
552 
553  // get autoreg flag (note: let flag survive if originally set and no attribute)
554  if(token.ExistsAttributeInteger("autoregister"))
555  mAutoRegistered = (token.AttributeIntegerValue("autoregister"));
556  // report
557  FD_DRTI("Documentation::DoRead(): found " << mName << " " << mCType);
558  // do read
559  DoReadCore(rTr);
560  // done
561  rTr.ReadEnd(label);
562 }
563 
564 // token read
566  FD_DRTI("Documentation::DoReadCore()");
567  Token token;
568  mTextDoc="";
569  mHtmlDoc="";
570  mKeywords="";
571 
572  // sense and digest pre 2.16 format
573  rTr.Peek(token);
574  if(token.IsString()) {
575  mName=token.StringValue();
576  size_t pos=mName.find("::");
577  if(pos!=std::string::npos) mName=mName.substr(pos+2);
578  mPlugIn=token.StringValue();
579  pos=mPlugIn.find("::");
580  if(pos!=std::string::npos) mPlugIn=mPlugIn.substr(0,pos);
581  else mPlugIn = "CoreFaudes";
582  rTr.ReadString();
583  mCType="";
584  rTr.Peek(token);
585  if(token.IsOption())
586  mCType = rTr.ReadOption();
587  while(true) {
588  rTr.Peek(token);
589  if(token.IsBegin())
590  if(token.StringValue()=="TextDoc") {
591  rTr.ReadBegin("TextDoc");
592  mTextDoc = rTr.ReadString();
593  rTr.ReadEnd("TextDoc");
594  continue;
595  }
596  if(token.IsBegin())
597  if(token.StringValue()=="HtmlDoc") {
598  rTr.ReadBegin("HtmlDoc");
599  mHtmlDoc = rTr.ReadString();
600  rTr.ReadEnd("HtmlDoc");
601  continue;
602  }
603  if(token.IsBegin())
604  if(token.StringValue()=="Keywords") {
605  rTr.ReadBegin("Keywords");
606  while(!rTr.Eos("Keywords"))
607  AddKeyword(rTr.ReadString());
608  rTr.ReadEnd("Keywords");
609  continue;
610  }
611  break;
612  }
613  return;
614  } // end pre 2.16 format
615 
616  // loop other known entries
617  while(true) {
618  rTr.Peek(token);
619  // do the read: docu
620  if(token.IsBegin())
621  if(token.StringValue()=="Documentation") {
622  if(token.ExistsAttributeString("ref"))
623  mHtmlDoc=token.AttributeStringValue("ref");
624  rTr.ReadText("Documentation",mTextDoc);
625  continue;
626  }
627  // do the read: keys
628  if(token.IsBegin())
629  if(token.StringValue()=="Keywords") {
630  rTr.ReadBegin("Keywords");
631  while(!rTr.Eos("Keywords"))
632  AddKeyword(rTr.ReadString());
633  rTr.ReadEnd("Keywords");
634  continue;
635  }
636  // unknown -> derived class take over
637  break;
638  }
639 }
640 
641 
642 // token write
643 void Documentation::DoWrite(TokenWriter& rTw, const std::string& rLabel, const Type* pContext) const {
644  // ignore
645  (void) pContext;
646  // figure my section
647  std::string label = rLabel;
648  if(label=="") label="Documentation";
649  // begin tag
650  Token btag;
651  btag.SetBegin(label);
652  if(mPlugIn!="" && mName!="")
653  btag.InsAttribute("name",mPlugIn+"::"+mName);
654  if(mPlugIn=="" && mName!="")
655  btag.InsAttribute("name",mName);
656  if(mCType!="")
657  btag.InsAttribute("ctype",mCType);
658  if(mAutoRegistered)
659  btag.InsAttributeBoolean("autoregister",true);
660  rTw << btag;
661  // data
662  DoWriteCore(rTw);
663  // end tag
664  rTw.WriteEnd(label);
665 }
666 
667 // token write
669  // write text doc
670  if(mTextDoc!="" || mHtmlDoc!="") {
671  Token btag;
672  btag.SetBegin("Documentation");
673  if(mHtmlDoc!="")
674  btag.InsAttributeString("ref",mHtmlDoc);
675  rTw.WriteText(btag,mTextDoc);
676  }
677  // write keys
678  int ksz=KeywordsSize();
679  if(ksz>0) {
680  rTw.WriteBegin("Keywords");
681  for(int i=0; i<ksz; i++)
682  rTw.WriteString(KeywordAt(i));
683  rTw.WriteEnd("Keywords");
684  }
685 }
686 
687 
688 
689 /*
690 ********************************************************************
691 ********************************************************************
692 ********************************************************************
693 
694 Implementation of class TypeDefinition
695 
696 ********************************************************************
697 ********************************************************************
698 ********************************************************************
699 */
700 
701 
702 // faudes type (cannot do autoregister)
708 
709 
710 // Typedefinition constructor function
711 TypeDefinition* TypeDefinition::Constructor(Type* pProto, const std::string& rTypeName){
712  FD_DRTI("TypeDefinition::Construct(" << typeid(*pProto).name() << ", " << rTypeName << ")");
713  TypeDefinition* td = new TypeDefinition();
714  td->Prototype(pProto);
715  std::string name=rTypeName;
716  if(name=="") name=typeid(*pProto).name();
717  td->Name(name);
718  return(td);
719 }
720 
721 
722 // clear (all except prototype)
724  FD_DRTI("TypeDefinition::Clear()");
725  // call base
727  // my members
728  mXElementTag="";
729 }
730 
731 
732 // std faudes type
734  // assign base members
736  // assign my members
738  // special member
739  if(mpType) delete mpType;
740  mpType=0;
741  if(rSrc.mpType)
742  mpType=rSrc.mpType->New();
743 }
744 
745 // std faudes type
746 bool TypeDefinition::DoEqual(const TypeDefinition& rOther) const {
747  // test base members
748  if(!Documentation::DoEqual(rOther)) return false;
749  // test my members
750  if(mXElementTag!=rOther.mXElementTag) return false;
751  return true;
752 }
753 
754 
755 // token io
756 void TypeDefinition::DoRead(TokenReader& rTr, const std::string& rLabel, const Type* pContext) {
757  FD_DRTI("TypeDefinition::DoRead(): file " << rTr.FileName());
758  // ignore
759  (void) pContext;
760  // figure my section
761  std::string label = rLabel;
762  if(label=="") label="TypeDefinition";
763  // base can handle this
764  Documentation::DoRead(rTr,label,pContext);
765  // my members
766 }
767 
768 // token io
770  FD_DRTI("TypeDefinition::DoReadCore(): file " << rTr.FileName());
771  // call base core
773  // my data
774  while(true) {
775  Token token;
776  rTr.Peek(token);
777  // element tag
778  if(token.IsBegin())
779  if(token.StringValue()=="XElementTag") {
780  rTr.ReadBegin("XElementTag",token);
781  if(token.ExistsAttributeString("value"))
782  mXElementTag=token.AttributeStringValue("value");
783  rTr.ReadEnd("XElementTag");
784  continue;
785  }
786  // break un unknown
787  break;
788  }
789 }
790 
791 // token io
792 void TypeDefinition::DoWrite(TokenWriter& rTw, const std::string& rLabel, const Type* pContext) const {
793  // label
794  std::string label=rLabel;
795  if(label=="") label="TypeDefinition";
796  // base can handle
797  Documentation::DoWrite(rTw,label,pContext);
798 }
799 
800 // token io
802  FD_DRTI("TypeDefinition::DoWriteCore(): file " << rTw.FileName());
803  // call base core
805  // my data
806  if(mXElementTag!="") {
807  Token etag;
808  etag.SetEmpty("XElementTag");
809  etag.InsAttributeString("value", mXElementTag);
810  rTw << etag;
811  }
812 }
813 
814 
815 // access prototype
816 const Type* TypeDefinition::Prototype(void) const{
817  return(mpType);
818 }
819 
820 // set prototype
822  if(mpType) delete mpType;
823  mpType = pType;
824  // test factory method
825 #ifdef FAUDES_CHECKED
826  if(mpType!=0) {
827  Type* nobj = mpType->New();
828  if(typeid(*nobj) != typeid(*mpType)) {
829  FD_WARN("TypeDefinition::Prototype(): factory method not implemented for c++-type " << typeid(*pType).name());
830  }
831  delete nobj;
832  }
833 #endif
834 }
835 
836 // construct new object with faudes type
838  FD_DRTI("TypeDefinition::NewObject()");
839  // bail out
840  if(!mpType) return NULL;
841  // use prototype
842  return mpType->New();
843 }
844 
845 
846 
847 // parameter access
848 const std::string& TypeDefinition::XElementTag(void) const {
849  return mXElementTag;
850 }
851 
852 // parameter access
853 void TypeDefinition::XElementTag(const std::string& rTag) {
854  mXElementTag=rTag;
855 }
856 
857 
858 
859 } //namspace
860 
#define FD_DC(message)
#define FD_DRTI(message)
#define FD_WARN(message)
#define FAUDES_TYPE_IMPLEMENTATION_EQUAL(ftype, ctype, cbase)
Definition: cfl_types.h:909
#define FAUDES_TYPE_IMPLEMENTATION_COPY(ftype, ctype, cbase)
Definition: cfl_types.h:896
#define FAUDES_TYPE_IMPLEMENTATION_CAST(ftype, ctype, cbase)
Definition: cfl_types.h:898
#define FAUDES_TYPE_IMPLEMENTATION_ASSIGN(ftype, ctype, cbase)
Definition: cfl_types.h:901
#define FAUDES_TYPE_IMPLEMENTATION_NEW(ftype, ctype, cbase)
Definition: cfl_types.h:894
int KeywordsSize(void) const
Definition: cfl_types.cpp:477
virtual void DoWriteCore(TokenWriter &rTw) const
Definition: cfl_types.cpp:668
bool DoEqual(const Documentation &rOther) const
Definition: cfl_types.cpp:374
std::string mTextDoc
Definition: cfl_types.h:1330
std::string mKeywords
Definition: cfl_types.h:1336
void AddKeyword(const std::string &rKeyword)
Definition: cfl_types.cpp:416
virtual void MergeDocumentation(TokenReader &rTr)
Definition: cfl_types.cpp:492
const std::string & HtmlDoc(void) const
Definition: cfl_types.cpp:401
const std::string & Name(void) const
Definition: cfl_types.cpp:397
std::string KeywordAt(int pos) const
Definition: cfl_types.cpp:453
const std::string & Keywords(void) const
Definition: cfl_types.cpp:402
static const char mDelim
Definition: cfl_types.h:1339
bool ApplicationRegistered(void) const
Definition: cfl_types.cpp:404
std::string mCType
Definition: cfl_types.h:1327
std::string mHtmlDoc
Definition: cfl_types.h:1333
const std::string & PlugIn(void) const
Definition: cfl_types.cpp:398
std::string MatchKeyword(const std::string &rPattern) const
Definition: cfl_types.cpp:426
virtual void DoWrite(TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const
Definition: cfl_types.cpp:643
const std::string & TextDoc(void) const
Definition: cfl_types.cpp:400
const std::string & CType(void) const
Definition: cfl_types.cpp:399
bool AutoRegistered(void) const
Definition: cfl_types.cpp:403
void DoAssign(const Documentation &rSrc)
Definition: cfl_types.cpp:364
std::string mPlugIn
Definition: cfl_types.h:1324
virtual void DoReadCore(TokenReader &rTr)
Definition: cfl_types.cpp:565
virtual void DoRead(TokenReader &rTr, const std::string &rLabel="", const Type *pContext=0)
Definition: cfl_types.cpp:514
void ReadText(const std::string &rLabel, std::string &rText)
std::string ReadOption(void)
bool Eos(const std::string &rLabel)
void SeekBegin(const std::string &rLabel)
void ReadEnd(const std::string &rLabel)
std::string ReadString(void)
void ReadBegin(const std::string &rLabel)
bool Peek(Token &token)
std::string FileName(void) const
std::string FileName(void) const
std::string Str(void)
void WriteText(const std::string &rText)
void WriteComment(const std::string &rComment)
void WriteString(const std::string &rString)
void WriteEnd(const std::string &rLabel)
void WriteBegin(const std::string &rLabel)
const std::string & StringValue(void) const
Definition: cfl_token.cpp:178
Int AttributeIntegerValue(const std::string &name)
Definition: cfl_token.cpp:397
bool IsString(void) const
Definition: cfl_token.cpp:244
void InsAttributeBoolean(const std::string &name, Int value)
Definition: cfl_token.cpp:337
bool ExistsAttributeString(const std::string &name)
Definition: cfl_token.cpp:356
bool IsBegin(void) const
Definition: cfl_token.cpp:259
void SetEmpty(const std::string &rName)
Definition: cfl_token.cpp:106
void InsAttribute(const std::string &name, const std::string &value)
Definition: cfl_token.cpp:300
void SetBegin(const std::string &rName)
Definition: cfl_token.cpp:92
bool ExistsAttributeInteger(const std::string &name)
Definition: cfl_token.cpp:366
void InsAttributeString(const std::string &name, const std::string &value)
Definition: cfl_token.cpp:310
bool IsOption(void) const
Definition: cfl_token.cpp:239
const std::string & AttributeStringValue(const std::string &name)
Definition: cfl_token.cpp:386
bool DoEqual(const TypeDefinition &rOther) const
Definition: cfl_types.cpp:746
virtual void DoWrite(TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const
Definition: cfl_types.cpp:792
virtual void DoReadCore(TokenReader &rTr)
Definition: cfl_types.cpp:769
virtual void DoWriteCore(TokenWriter &rTw) const
Definition: cfl_types.cpp:801
void DoAssign(const TypeDefinition &rSrc)
Definition: cfl_types.cpp:733
std::string mXElementTag
Definition: cfl_types.h:1605
virtual void DoRead(TokenReader &rTr, const std::string &rLabel="", const Type *pContext=0)
Definition: cfl_types.cpp:756
const Type * Prototype(void) const
Definition: cfl_types.cpp:816
Type * NewObject(void) const
Definition: cfl_types.cpp:837
const std::string & XElementTag(void) const
Definition: cfl_types.cpp:848
static TypeRegistry * G()
const TypeDefinition * Definitionp(const std::string &rTypeName) const
virtual void DoRead(TokenReader &rTr, const std::string &rLabel="", const Type *pContext=0)
Definition: cfl_types.cpp:308
virtual void DoWrite(TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const
Definition: cfl_types.cpp:283
virtual const TypeDefinition * TypeDefinitionp(void) const
Definition: cfl_types.cpp:128
bool DoEqual(const Type &rOther) const
Definition: cfl_types.cpp:112
bool operator==(const Type &rOther) const
Definition: cfl_types.cpp:89
void DWrite(const Type *pContext=0) const
Definition: cfl_types.cpp:226
virtual Token XBeginTag(const std::string &rLabel="", const std::string &rFallbackLabel="") const
Definition: cfl_types.cpp:316
void Read(const std::string &rFileName, const std::string &rLabel="", const Type *pContext=0)
Definition: cfl_types.cpp:262
virtual const std::string & Name(void) const
Definition: cfl_types.cpp:123
Type & operator=(const Type &rSrc)
Definition: cfl_types.cpp:99
std::string ToSText(void) const
Definition: cfl_types.cpp:178
static std::string msStringEmpty
Definition: cfl_types.h:859
std::string ToString(const std::string &rLabel="", const Type *pContext=0) const
Definition: cfl_types.cpp:170
void FromString(const std::string &rString, const std::string &rLabel="", const Type *pContext=0)
Definition: cfl_types.cpp:276
virtual void XWrite(const std::string &pFileName, const std::string &rLabel="", const Type *pContext=0) const
Definition: cfl_types.cpp:201
virtual ~Type(void)
Definition: cfl_types.cpp:51
virtual void Clear(void)
Definition: cfl_types.cpp:72
virtual Type & Assign(const Type &rSrc)
Definition: cfl_types.cpp:77
virtual Type * New(void) const
Definition: cfl_types.cpp:54
virtual void DoSWrite(TokenWriter &rTw) const
Definition: cfl_types.cpp:300
void SWrite(void) const
Definition: cfl_types.cpp:251
virtual void DoXWrite(TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const
Definition: cfl_types.cpp:289
virtual Type * Copy(void) const
Definition: cfl_types.cpp:60
std::string ToText(const std::string &rLabel="", const Type *pContext=0) const
Definition: cfl_types.cpp:186
static std::string msStringVoid
Definition: cfl_types.h:858
void Write(const Type *pContext=0) const
Definition: cfl_types.cpp:140
virtual void DoDWrite(TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const
Definition: cfl_types.cpp:294
bool operator!=(const Type &rOther) const
Definition: cfl_types.cpp:94
void DoAssign(const Type &rSrc)
Definition: cfl_types.cpp:107
virtual const std::string & TypeName(void) const
Definition: cfl_types.cpp:133
virtual bool Equal(const Type &rOther) const
Definition: cfl_types.cpp:84
virtual const Type * Cast(const Type *pOther) const
Definition: cfl_types.cpp:66

libFAUDES 2.33c --- 2025.05.15 --- c++ api documentaion by doxygen