tp_timeconstraint.cpp
Go to the documentation of this file.
1 /* tp_timecontraint.cpp -- model of timeconstraints in timed automata */
2 
3 
4 /* Timeplugin for FAU Discrete Event Systems Library (libfaudes)
5 
6  Copyright (C) 2006 B Schlein
7  Copyright (C) 2007 Thomas Moor
8  Exclusive copyright is granted to Klaus Schmidt
9 
10 */
11 
12 
13 
14 #include "tp_timeconstraint.h"
15 
16 namespace faudes {
17 
18 
19 /********************************************************************
20 
21  Implementation of ClockSet
22 
23 ********************************************************************/
24 
25 
26 // std faudes type (cannot do New() with macro)
27 FAUDES_TYPE_IMPLEMENTATION_COPY(Void,ClockSet,NameSet)
28 FAUDES_TYPE_IMPLEMENTATION_CAST(Void,ClockSet,NameSet)
29 FAUDES_TYPE_IMPLEMENTATION_ASSIGN(Void,ClockSet,NameSet)
30 FAUDES_TYPE_IMPLEMENTATION_EQUAL(Void,ClockSet,NameSet)
31 
32 // ClockSet(void);
33 ClockSet::ClockSet(void) : NameSet() {
34  // overwrite default static symboltable
35  mpSymbolTable=GlobalClockSymbolTablep();
36  NameSet::Name("Clocks");
37  FD_DC("ClockSet("<<this<<")::ClockSet() with csymtab "<< SymbolTablep());
38 }
39 
40 // ClockSet(clockset)
41 ClockSet::ClockSet(const ClockSet& rOtherSet) : NameSet(rOtherSet) {
42  FD_DC("ClockSet(" << this << ")::ClockSet(rOtherSet " << &rOtherSet << ")");
43 }
44 
45 // ClockSet(file);
46 ClockSet::ClockSet(const std::string& rFilename, const std::string& rLabel) : NameSet() {
47  // overwrite default static symboltable
49  NameSet::Name("Clocks");
50  // read file
51  NameSet::Read(rFilename,rLabel);
52 }
53 
54 // Clockset::New()
55 ClockSet* ClockSet::New(void) const {
56  ClockSet* res = new ClockSet();
58  return res;
59 }
60 
61 // DoAssign()
62 void ClockSet::DoAssign(const ClockSet& rSourceSet) {
63  // call base
64  NameSet::DoAssign(rSourceSet);
65 }
66 
67 // DoEqual()
68 bool ClockSet::DoEqual(const ClockSet& rOtherSet) const {
69  // call base
70  return NameSet::DoEqual(rOtherSet);
71 }
72 
73 
74 
75 // ClockSet::GlobalClockSymbolTablep
76 // (initialize on first use pattern)
78  static SymbolTable fls;
79  return &fls;
80 }
81 
82 
83 
84 
85 
86 
87 /********************************************************************
88 
89  Implementation of ElemConstraint
90 
91 ********************************************************************/
92 
93 
94 // helper (conversion from operatorname to string
96  switch(op){
97  case LessThan: return "LT";
98  case GreaterThan: return "GT";
99  case LessEqual: return "LE";
100  case GreaterEqual: return "GE";
101  }
102  return "Inalid";
103 }
104 
105 
106 // Constructor
108  Set(0,LessThan,0);
109 }
110 
111 // Constructor
112 ElemConstraint::ElemConstraint(Idx clockindex, Operator op, const Time::Type timeconst) {
113  Set(clockindex,op,timeconst);
114 }
115 
116 
117 // Set(clockindex, op, timeconst)
118 void ElemConstraint::Set(Idx clockindex, Operator op, const Time::Type timeconst) {
119  mClockIndex = clockindex;
120  mCompOperator = op;
121  mTimeConstant = timeconst;
122 }
123 
124 // Clock(clockindex)
126  mClockIndex=clockindex;
127  return mClockIndex;
128 }
129 
130 // Clock()
132  return mClockIndex;
133 }
134 
135 // CompOperator(newOp)
137  mCompOperator = newOp;
138 }
139 
140 
141 // CompOperator()
143  return mCompOperator;
144 }
145 
146 
147 // TimeConstant(newTimeConst)
149  mTimeConstant = newTimeConst;
150 }
151 
152 // TimeConstant()
154  return mTimeConstant;
155 }
156 
157 // Str() const
158 std::string ElemConstraint::Str(void) const {
159  std::stringstream resstream;
160  resstream << "(" << mClockIndex << " "
161  << OperatorName(mCompOperator) << " " << mTimeConstant << ")";
162  std::string result = resstream.str();
163  return result;
164 }
165 
166 // operator==
167 bool ElemConstraint::operator== (const ElemConstraint & otherClockConstraint) const {
168  return ( mClockIndex == otherClockConstraint.mClockIndex
169  && mCompOperator == otherClockConstraint.mCompOperator
170  && mTimeConstant == otherClockConstraint.mTimeConstant );
171 }
172 
173 // operator!=
174 bool ElemConstraint::operator!= (const ElemConstraint & otherClockConstraint) const {
175  return !(operator==(otherClockConstraint));
176 }
177 
178 // operator <
179 bool ElemConstraint::operator < (const ElemConstraint& otherElemConstraint) const {
180  if (mClockIndex < otherElemConstraint.mClockIndex) return true;
181  if (mClockIndex > otherElemConstraint.mClockIndex) return false;
182  if (mCompOperator < otherElemConstraint.mCompOperator) return true;
183  if (mCompOperator > otherElemConstraint.mCompOperator) return false;
184  if (mTimeConstant < otherElemConstraint.mTimeConstant) return true;
185  return false;
186 }
187 
188 
189 /********************************************************************
190 
191  Implementation of TimeConstraint
192 
193 ********************************************************************/
194 
195 
196 
197 // empty constructor
199  FD_DC("TimeConstraint(" << this << ")::TimeConstraint()");
201  mName="TimeConstraint";
202 }
203 
204 // read file constructor
205 TimeConstraint::TimeConstraint(const std::string& rFilename, const std::string& rLabel) {
206  FD_DC("TimeConstraint(" << this << ")::TimeConstraint(" << rFilename << ")");
208  Read(rFilename, rLabel);
209 }
210 
211 // constructor
212 TimeConstraint::TimeConstraint(const TimeConstraint& rOtherTimeConstraint) {
213  FD_DC("TimeConstraint(" << this << ")::TimeConstraint(other)");
214  mName=rOtherTimeConstraint.mName;
215  mpClockSymbolTable= rOtherTimeConstraint.mpClockSymbolTable;
216  mClockConstraints = rOtherTimeConstraint.ClockConstraints();
217 }
218 
219 
220 // Destructor
222 }
223 
224 // ClockSymbolTablep()
226  return mpClockSymbolTable;
227 }
228 
229 // ClockSymbolTablep(pSymTab)
231  if(mClockConstraints.empty()) {
232  mpClockSymbolTable=pSymTab;
233  } else {
234  // TODO: implement reindex
235  FD_ERR("TimeConstraint::SymboltTable(pSymTab): "
236  << "set SymbolTable not implemented!!");
237  abort();
238  }
239 }
240 
241 // Empty()
242 bool TimeConstraint::Empty(void) const {
243  return mClockConstraints.empty();
244 }
245 
246 // Size of set of ElemConstraints
248  return (Idx)mClockConstraints.size();
249 }
250 
251 // InsClock()
252 Idx TimeConstraint::InsClock(const std::string& rClockName) const {
253  return mpClockSymbolTable->InsEntry(rClockName);
254 }
255 
256 // ClockName(clockindex)
257 std::string TimeConstraint::ClockName(Idx clockindex) const {
258  return mpClockSymbolTable->Symbol(clockindex);
259 }
260 
261 // ClockIndex(clockname)
262 Idx TimeConstraint::ClockIndex(const std::string& rClockName) const {
263  return mpClockSymbolTable->Index(rClockName);
264 }
265 
266 
267 // EStr(ElemConstraint) const
268 std::string TimeConstraint::EStr(const ElemConstraint& rElemConstraint) const {
269  std::stringstream resstream;
270  resstream << "(" << ClockName(rElemConstraint.Clock()) << "[" << rElemConstraint.Clock()
271  << "] " << ElemConstraint::OperatorName(rElemConstraint.CompOperator()) << " "
272  << rElemConstraint.TimeConstant() << ")";
273  std::string result = resstream.str();
274  return result;
275 }
276 
277 // Insert(rNewConstr)
279  FD_DC("TimeConstraint(" << this << ")::Insert(" << rNewConstr.Str() << ")");
280  if(rNewConstr.Clock()<=0 || ClockName(rNewConstr.Clock())=="") {
281  std::stringstream errstr;
282  errstr << "Invalid ElemConstraint: \"" << rNewConstr.Str();
283  throw Exception("TimeConstraint::Insert", errstr.str(), 55);
284  }
285  return mClockConstraints.insert(rNewConstr).first;
286 }
287 
288 // Insert(clock, op, timeconst)
290  FD_DC("TimeConstraint(" << this << ")::Insert("
291  << clockindex << " " << ElemConstraint::OperatorName(op) << " " << timeconst << ")");
292  ElemConstraint newconstr(clockindex,op,timeconst);
293  return Insert(newconstr);
294 }
295 
296 
297 // Insert(clock, op, timeconst)
299  const std::string clockname,
300  Operator op,
301  const Time::Type timeconst)
302 {
303  FD_DC("TimeConstraint(" << this << ")::Insert(\""
304  << clockname << "\" " << ElemConstraint::OperatorName(op) << " " << timeconst << ")");
305  Idx clockindex = InsClock(clockname);
306  return Insert(clockindex,op,timeconst);
307 }
308 
309 // Insert(rNewConstraints)
310 void TimeConstraint::Insert(const std::list<ElemConstraint>& rNewConstraints) {
311  FD_DC("TimeConstraint(" << this << ")::Insert(const std::list<ElemConstraint>&)");
312  // HELPERS
313  std::list<ElemConstraint>::const_iterator it;
314  // ALGORITHM
315  for(it = rNewConstraints.begin(); it != rNewConstraints.end(); it++)
316  Insert(*it);
317 }
318 
319 
320 // Insert(rOtherTimeConstraint)
321 void TimeConstraint::Insert(const TimeConstraint& rOtherTimeConstraint) {
322  FD_DC("TimeConstraint(" << this << ")::Insert(" << rOtherTimeConstraint.ToString() << ")");
323  // HELPERS
324  Iterator it;
325  // ALGORITHM
326  if(mpClockSymbolTable != rOtherTimeConstraint.mpClockSymbolTable) {
327  FD_ERR("TimeConstraint::Insert "
328  << "SymbolTable mismatch aka not implemented!!");
329  abort();
330  }
331  for(it = rOtherTimeConstraint.Begin(); it != rOtherTimeConstraint.End(); it++) {
332  Insert(*it);
333  }
334 }
335 
336 // ClockConstraints()
337 std::set<ElemConstraint> TimeConstraint::ClockConstraints(void) const {
338  return mClockConstraints;
339 }
340 
341 
342 // EraseByClock(clock)
344  FD_DC("TimeConstraint(" << this << ")::EraseByClock(" << clock << ") const");
345  // HELPERS
346  iterator lit,uit;
347 
348  // ALGORITHM
351 
352  if(lit==mClockConstraints.end())
353  return false;
354 
355  mClockConstraints.erase(lit,uit);
356  return true;
357 }
358 
359 
360 // Erase(it)
362  FD_DC("TimeConstraint(" << this << ")::Erase(" << it->Str() << ") const");
363  if(it==End()) return it;
364  iterator del= it; //cit
365  it++;
366  mClockConstraints.erase(del);
367  return it;
368 }
369 
370 
371 // Erase(rElemConstr)
372 bool TimeConstraint::Erase(const ElemConstraint& rElemConstr) {
373  FD_DC("TimeConstraint(" << this << ")::Erase(" << rElemConstr.Str() << ") const");
374  // HELPERS
375  iterator it;
376  // ALGORITHM
377  it = mClockConstraints.find(rElemConstr);
378  if(it == End()) return false;
379  mClockConstraints.erase(it);
380  return true;
381 }
382 
383 // Erase(clock, op, timeconst)
384 bool TimeConstraint::Erase(Idx clockindex, Operator op, const Time::Type timeconst) {
385  FD_DC("TimeConstraint(" << this << ")::Erase("
386  << clockindex << " " << ElemConstraint::OperatorName(op) << " " << timeconst << ")");
387  ElemConstraint newconstr(clockindex,op,timeconst);
388  return Erase(newconstr);
389 }
390 
391 
392 // Erase(clock, op, timeconst)
393 bool TimeConstraint::Erase(const std::string& clockname, Operator op, const Time::Type timeconst)
394 {
395  FD_DC("TimeConstraint(" << this << ")::Erase(\""
396  << clockname << "\" " << ElemConstraint::OperatorName(op) << " " << timeconst << ")");
397  Idx clockindex = ClockIndex(clockname);
398  return Erase(clockindex,op,timeconst);
399 }
400 
401 // Exists(rElemConstr)
402 bool TimeConstraint::Exists(const ElemConstraint& rElemConstr) const {
403  FD_DC("TimeConstraint(" << this << ")::ExistsElConstr(" << rElemConstr.Str() << ") const");
404  // HELPERS
405  Iterator it;
406  // ALGORITHM
407  it = mClockConstraints.find(rElemConstr);
408  return (it != End()) ;
409 }
410 
411 
412 // Deletes all ElemConstraints
414  FD_DC("TimeConstraint(" << this << ")::Clear() const");
415  mClockConstraints.clear();
416 }
417 
418 
419 
420 // Iterator Begin() const
422  return mClockConstraints.begin();
423 }
424 
425 
426 // iterator End() const
428  return mClockConstraints.end();
429 }
430 
431 // reverse iterator RBegin()
433  return mClockConstraints.rbegin();
434 }
435 
436 // reverse iterator REnd() const
438  return mClockConstraints.rend();
439 }
440 
441 // iterator Begin(clock) const
444 }
445 
446 // iterator End(clock) const
448  return mClockConstraints.lower_bound(ElemConstraint(clock+1,ElemConstraint::GreaterEqual,0));
449 }
450 
451 // returns ClockSet filled with clocks used by ElemConstraints
453  FD_DC("TimeConstraint(" << this << ")::ActiveClocks() const");
454  //Helpers
455  ClockSet result;
457  Iterator it;
458  // Algorithm
459  for(it = Begin(); it != End(); it++)
460  result.Insert(it->Clock());
461  return result;
462 }
463 
464 // valid timeinterval for given clock
465 TimeInterval TimeConstraint::Interval(const std::string& clockname) const{
466  Idx clockindex = ClockIndex(clockname);
467  return Interval(clockindex);
468 }
469 
470 // valid timeinterval for given clock
472  FD_DC("TimeConstraint(" << this << ")::Interval(" << clockindex <<") const");
473  TimeInterval res;
474  TimeInterval tint;
475  Iterator it;
476  for(it = Begin(clockindex); it != End(clockindex); it++) {
477  FD_DC("TimeConstraint(" << this << ")::Interval: elemconstraint: " << it->Str());
478  tint.SetFull();
479  if(it->CompOperator() == ElemConstraint::LessThan) {
480  tint.UB(it->TimeConstant());
481  tint.UBincl(false);
482  }
483  if(it->CompOperator() == ElemConstraint::LessEqual) {
484  tint.UB(it->TimeConstant());
485  tint.UBincl(true);
486  }
487  if(it->CompOperator() == ElemConstraint::GreaterThan) {
488  tint.LB(it->TimeConstant());
489  tint.LBincl(false);
490  }
491  if(it->CompOperator() == ElemConstraint::GreaterEqual) {
492  tint.LB(it->TimeConstant());
493  tint.LBincl(true);
494  }
495  FD_DC("TimeConstraint(" << this << ")::Interval: interval: " << tint.Str());
496  res.Intersect(tint);
497  }
498  return res;
499 }
500 
501 
502 // set valid timeinterval for given clock
503 void TimeConstraint::Interval(const std::string& clockname, const TimeInterval& rInterval) {
504  Idx clockindex = InsClock(clockname);
505  Interval(clockindex,rInterval);
506 }
507 
508 // set valid timeinterval for given clock
509 void TimeConstraint::Interval(Idx clockindex, const TimeInterval& rInterval) {
510  FD_DC("TimeConstraint(" << this << ")::Interval(" << clockindex <<", " << rInterval.Str() << ") ");
511  EraseByClock(clockindex);
512  if(rInterval.LBinf()==false) {
513  ElemConstraint newconstraint;
514  newconstraint.Clock(clockindex);
515  if(rInterval.LBincl())
517  else
519  newconstraint.TimeConstant(rInterval.LB());
520  Insert(newconstraint);
521  }
522  if(rInterval.UBinf()==false) {
523  ElemConstraint newconstraint;
524  newconstraint.Clock(clockindex);
525  if(rInterval.UBincl())
527  else
528  newconstraint.CompOperator(ElemConstraint::LessThan);
529  newconstraint.TimeConstant(rInterval.UB());
530  Insert(newconstraint);
531  }
532 }
533 
534 
535 // Minimize()
537  ClockSet aclocks=ActiveClocks();
538  ClockSet::Iterator cit;
539  for(cit=aclocks.Begin(); cit != aclocks.End(); cit++) {
540  TimeInterval tint=Interval(*cit);
541  Interval(*cit, tint);
542  }
543 }
544 
545 // operator==
546 bool TimeConstraint::operator== (const TimeConstraint & rOther) const {
547  ClockSet aclocks=ActiveClocks();
548  aclocks.InsertSet(rOther.ActiveClocks());
549  ClockSet::Iterator cit;
550  for(cit=aclocks.Begin(); cit != aclocks.End(); cit++) {
551  TimeInterval tint=Interval(*cit);
552  if(rOther.Interval(*cit)!=tint) return false;
553  }
554  return true;
555 }
556 
557 // operator!=
558 bool TimeConstraint::operator!= (const TimeConstraint & rOther) const {
559  return !(operator==(rOther));
560 }
561 
562 
563 // Write()
564 void TimeConstraint::Write(void) const {
566  Write(tw);
567 }
568 
569 // Write(rFilename, rLabel, openmode)
570 void TimeConstraint::Write(const std::string& rFilename, const std::string& rLabel,
571  std::ios::openmode openmode) const {
572  try {
573  TokenWriter tw(rFilename, openmode);
574  Write(tw, rLabel);
575  }
576  catch (std::ios::failure&) {
577  std::stringstream errstr;
578  errstr << "Exception opening/writing file \"" << rFilename << "\"";
579  throw Exception("TimeConstraint::Write", errstr.str(), 2);
580  }
581 }
582 
583 // Write(tw)
585  Write(tw, Name());
586 }
587 
588 
589 // Write(tw, rLabel)
590 void TimeConstraint::Write(TokenWriter& tw, const std::string& rLabel) const {
591  Token token;
592  Iterator it;
593  int oldcolumns = tw.Columns();
594  tw.Columns(3);
595  tw.WriteBegin(rLabel);
596  for (it = Begin(); it != End(); ++it) {
597  // 1. clock
598  if(ClockName(it->Clock()) != "") {
599  token.SetString(ClockName(it->Clock()));
600  tw << token;
601  } else {
602  token.SetInteger(it->Clock());
603  tw << token;
604  }
605  // 2. operator
606  token.SetString(ElemConstraint::OperatorName(it->CompOperator()));
607  tw << token;
608  // 3. timeconst
609  token.SetFloat((Float) it->TimeConstant());
610  tw << token;
611  }
612  tw.WriteEnd(rLabel);
613  tw.Columns(oldcolumns);
614 }
615 
616 
617 // ToString()
618 std::string TimeConstraint::ToString(void) const {
620  Write(tw);
621  return tw.Str();
622 }
623 
624 
625 // DWrite()
626 void TimeConstraint::DWrite(void) const {
628  DWrite(tw);
629 }
630 
631 // DWrite(tw)
633  Token token;
634  Iterator it;
635  tw.WriteBegin(Name());
636  for (it = Begin(); it != End(); ++it) {
637  tw << EStr(*it);
638  }
639  tw.WriteEnd(Name());
640 }
641 
642 // Read(rFilename, rLabel)
643 void TimeConstraint::Read(const std::string& rFilename, const std::string& rLabel) {
644  TokenReader tr(rFilename);
645  Read(tr,rLabel);
646 }
647 
648 // Read(rTr, rLabel)
649 void TimeConstraint::Read(TokenReader& rTr, const std::string& rLabel) {
650  Clear();
651  Name(rLabel);
652  rTr.ReadBegin(rLabel);
653 
654  std::string clockname;
655  Time::Type timeconst;
657  Token token;
658  while(rTr.Peek(token)) {
659  // 0. check for end
660  if (token.Type() == Token::End) {
661  break;
662  }
663  // 1. read clock
664  rTr >> token;
665  if (token.Type() != Token::String) {
666  std::stringstream errstr;
667  errstr << "Invalid clock" << rTr.FileLine();
668  throw Exception("TimeConstraint::Read", errstr.str(), 56);
669  }
670  clockname=token.StringValue();
671  // 2. read operator
672  rTr >> token;
673  if (token.Type() != Token::String) {
674  std::stringstream errstr;
675  errstr << "Invalid operator" << rTr.FileLine();
676  throw Exception("TimeConstraint::Read", errstr.str(), 56);
677  }
678  if(token.StringValue() == "LE") {
679  compop = ElemConstraint::LessEqual;
680  } else if(token.StringValue() == "GE") {
682  } else if(token.StringValue() == "LT") {
683  compop = ElemConstraint::LessThan;
684  } else if(token.StringValue() == "GT") {
685  compop = ElemConstraint::GreaterThan;
686  } else {
687  std::stringstream errstr;
688  errstr << "Invalid operator value " << rTr.FileLine();
689  throw Exception("TimedTransSet::ReadTimeConstraint", errstr.str(), 56);
690  }
691  // 3. read timeconst
692  rTr >> token;
693  if (!token.IsFloat()) {
694  std::stringstream errstr;
695  errstr << "Invalid timeconstant" << rTr.FileLine();
696  throw Exception("TimeConstraint::Read", errstr.str(), 56);
697  }
698  timeconst=(Time::Type) token.FloatValue();
699  // 4. set constraint
700  Insert(clockname,compop,timeconst);
701  } // while not end
702  rTr.ReadEnd(rLabel);
703 }
704 
705 
706 // End Implementation of TimeConstraint
707 
708 
709 
710 } // namespace faudes
#define FD_DC(message)
Debug: optional report on container operations.
#define FD_ERR(message)
Debug: report more errors with file/line info.
#define FAUDES_TYPE_IMPLEMENTATION_EQUAL(ftype, ctype, cbase)
Definition: cfl_types.h:904
#define FAUDES_TYPE_IMPLEMENTATION_COPY(ftype, ctype, cbase)
Definition: cfl_types.h:891
#define FAUDES_TYPE_IMPLEMENTATION_CAST(ftype, ctype, cbase)
Definition: cfl_types.h:893
#define FAUDES_TYPE_IMPLEMENTATION_ASSIGN(ftype, ctype, cbase)
Definition: cfl_types.h:896
Container class to model a set of clocks.
virtual void DoAssign(const ClockSet &rSourceSet)
Assign from other clock set.
virtual bool DoEqual(const ClockSet &rOtherSet) const
Test equality with other clock set.
ClockSet(void)
Constructor.
static SymbolTable * GlobalClockSymbolTablep(void)
Get pointer to static clock SymbolTable (init on first use pattern)
Model of an elementary clock constraint formula.
bool operator<(const ElemConstraint &otherElemConstraint) const
Less operator for ordering in container classes.
Operator CompOperator(void) const
Get operator.
bool operator==(const ElemConstraint &otherElemConstraint) const
Test for equality.
Idx Clock(Idx newClock)
Set clock by index.
Operator
Typedef for comparison operators in elementary clock constraints.
Time::Type mTimeConstant
Time constant to compare with clock value.
Time::Type TimeConstant(void) const
Get time constant.
bool operator!=(const ElemConstraint &otherElemConstraint) const
Test for equality.
Operator mCompOperator
Comparative operator.
void Set(Idx clockindex, Operator op, Time::Type timeconst)
Set all values.
Idx Clock(void) const
Get clock by index.
std::string Str(void) const
Writes ElemConstraint to std::string.
void TimeConstant(Time::Type newTimeConst)
Set time constant.
Idx mClockIndex
Index of clock.
static std::string OperatorName(Operator op)
Conversion from symbolic operator to string.
void CompOperator(Operator newOp)
Set operator.
ElemConstraint(void)
Construct an (invalid) elementary clock constraint (clockindex 0)
Faudes exception class.
Set of indices with symbolic names.
Definition: cfl_nameset.h:69
virtual void InsertSet(const NameSet &rOtherSet)
Inserts all elements of rOtherSet.
bool DoEqual(const NameSet &rOtherSet) const
Test equality of configuration data.
Definition: cfl_nameset.cpp:92
SymbolTable * SymbolTablep(void) const
Get Pointer mpSymbolTable.
bool Insert(const Idx &rIndex)
Add an element by index.
SymbolTable * mpSymbolTable
Pointer to local SymbolTable.
Definition: cfl_nameset.h:428
void DoAssign(const NameSet &rSourceSet)
Assign from other name set.
Definition: cfl_nameset.cpp:83
A SymbolTable associates sybolic names with indices.
std::string Symbol(Idx index) const
Symbolic name lookup.
Idx InsEntry(Idx index, const std::string &rName)
Add new entry (aka symbolic name and index) to symboltable,.
Idx Index(const std::string &rName) const
Index lookup.
A TimeConstraint is a set of elementary clock constraints.
~TimeConstraint(void)
Destructor.
std::set< ElemConstraint > ClockConstraints(void) const
Returns copy of ClockConstraints.
Idx InsClock(const std::string &rClockName) const
Advertise clock to ClockSymbolTable and retrive index.
std::set< ElemConstraint >::const_iterator Iterator
Iterator to access ElemConstraints.
Iterator Erase(Iterator it)
Calls std::set::erase(iterator).
std::string ToString(void) const
Write to a std::string.
bool Exists(const ElemConstraint &rElemConstr) const
Checks if elementary clock constraint is contained in constraint.
Iterator End(void) const
Iterator to end of set.
std::string ClockName(Idx clockindex) const
Lookup clock name.
std::string EStr(const ElemConstraint &rElemConstr) const
Pretty printable string of elem.
bool Empty(void) const
Checks if TimeConstraint containts no ElemConstraints.
std::set< ElemConstraint > mClockConstraints
Set of elementary clock constraints.
Idx Size(void) const
Returns number of ElemConstraint s.
void DWrite(void) const
Write NameSet to console, debug version.
void Read(const std::string &rFileName, const std::string &rLabel="TimeConstraint")
Read from file.
TimeConstraint(void)
Construct an empty TimeConstraint (allways satisfied)
RIterator RBegin(void) const
Reverse iterator that yields the ElemConstraints in reverse order starting at the last element and en...
TimeInterval Interval(Idx clockindex) const
Given a clock, compute the timeinterval in which the constraint is satisfied.
bool operator==(const TimeConstraint &rOther) const
Test for equality.
void Minimize(void)
Minimize by eliminating redundant elementary constraints.
bool operator!=(const TimeConstraint &rOther) const
Test for equality.
std::set< ElemConstraint >::const_reverse_iterator RIterator
Reverse iterator to access ElemConstraints.
Idx ClockIndex(const std::string &rClockName) const
Lookup clock index.
RIterator REnd(void) const
Reverse iterator that yields the ElemConstraints in reverse order starting at the last element and en...
bool EraseByClock(Idx clock)
Removes all elementary clock constraints refering to a specified clock.
Iterator Begin(void) const
Iterator to begin of set.
std::string Name(void) const
Return name of Constraint.
SymbolTable * mpClockSymbolTable
SymbolTable for clock names.
std::set< ElemConstraint >::iterator iterator
nonconst iterator to access ElemConstraints
std::string mName
My name.
Iterator Insert(const ElemConstraint &rElemConstr)
Adds an elementary clock constraint to the time constraint.
void Clear(void)
Clear all.
ClockSet ActiveClocks(void) const
Returns a Clockset containing all clocks used by the TimeConstraint.
void Write(void) const
Write to console.
SymbolTable * ClockSymbolTablep(void) const
Get Pointer to mpClockSymbolTable.
Model of a time interval.
void LB(Time::Type time)
Set the lower bound to a given value.
bool UBinf(void) const
Test for upper bound infinity.
std::string Str(void) const
Pretty printable string.
void UBincl(bool incl)
Configures the upper bound to be inclusive.
void LBincl(bool incl)
Configures the lower bound to be inclusive.
void UB(Time::Type time)
Set the upper bound to a given value.
void SetFull(void)
Set to full (-inf, +inf)
bool LBinf(void) const
Test for lower bound infinity.
void Intersect(const TimeInterval &rOtherInterval)
Intersect this interval with other interval.
Int Type
Datatype for point on time axis.
A TokenReader reads sequential tokens from a file or string.
std::string FileLine(void) const
Return "filename:line".
void ReadEnd(const std::string &rLabel)
Close the current section by matching the previous ReadBegin().
void ReadBegin(const std::string &rLabel)
Open a section by specified label.
bool Peek(Token &token)
Peek next token.
A TokenWriter writes sequential tokens to a file, a string or stdout.
std::string Str(void)
Retrieve output as string (if in String mode)
void WriteEnd(const std::string &rLabel)
Write end label.
int Columns(void) const
Get number of columns in a line.
void WriteBegin(const std::string &rLabel)
Write begin label.
Tokens model atomic data for stream IO.
Definition: cfl_token.h:53
void SetInteger(const Int number)
Initialize as Integer token.
Definition: cfl_token.cpp:120
@ End
<\label> (end of section)
Definition: cfl_token.h:84
@ String
any string, space separated or quoted, must start with a letter
Definition: cfl_token.h:85
void SetString(const std::string &rName)
Initialize as String token.
Definition: cfl_token.cpp:84
void SetFloat(const faudes::Float number)
Initialize as Float token.
Definition: cfl_token.cpp:144
TokenType Type(void) const
Get token Type.
Definition: cfl_token.cpp:198
void Read(const std::string &rFileName, const std::string &rLabel="", const Type *pContext=0)
Read configuration data from file with label specified.
Definition: cfl_types.cpp:261
virtual Type * New(void) const
Construct on heap.
Definition: cfl_types.cpp:54
Iterator End(void) const
Iterator to the end of set.
Definition: cfl_baseset.h:1896
Iterator Begin(void) const
Iterator to the begin of set.
Definition: cfl_baseset.h:1891
const std::string & Name(void) const
Return name of TBaseSet.
Definition: cfl_baseset.h:1755
libFAUDES resides within the namespace faudes.
uint32_t Idx
Type definition for index type (allways 32bit)
double Float
Type definition for real type.
Classes ClockSet, ElemConstraint and TimeConstraint.

libFAUDES 2.32b --- 2024.03.01 --- c++ api documentaion by doxygen