Detailed Description

A TimeConstraint is a set of elementary clock constraints.

Semantically, the elementary constraints are combibed by conjunction, ie the TimeConstraint is satisfied if all ElemConstraint s are satisfied. This implementation also maintains the clock symboltable to may cloc indices to symbolic names.

Parameters
ClockConstraintsSet of elementary clock constraints

Definition at line 274 of file tp_timeconstraint.h.

#include <tp_timeconstraint.h>

Public Types

typedef std::set< ElemConstraint >::const_iterator Iterator
 Iterator to access ElemConstraints. More...
 
typedef std::set< ElemConstraint >::const_reverse_iterator RIterator
 Reverse iterator to access ElemConstraints. More...
 
typedef ElemConstraint::Operator Operator
 Convenience typedef for operators. More...
 

Public Member Functions

 TimeConstraint (void)
 Construct an empty TimeConstraint (allways satisfied) More...
 
 TimeConstraint (const TimeConstraint &rOtherTimeConstraint)
 Copy constructor. More...
 
 TimeConstraint (const std::string &rFilename, const std::string &rLabel="TimeConstraint")
 Constructor from file. More...
 
 ~TimeConstraint (void)
 Destructor. More...
 
SymbolTableClockSymbolTablep (void) const
 Get Pointer to mpClockSymbolTable. More...
 
void ClockSymbolTablep (SymbolTable *pSymTab)
 Set Pointer to mpClockSymbolTable. More...
 
void Write (void) const
 Write to console. More...
 
void Write (const std::string &rFileName, const std::string &rLabel="TimeConstraint", std::ios::openmode openmode=std::ios::out|std::ios::trunc) const
 Write to file with label (default: "TimeConstraint") and openmode (default: truncate file). More...
 
void Write (TokenWriter &tw) const
 Write to TokenWriter. More...
 
void Write (TokenWriter &tw, const std::string &rLabel) const
 Write to TokenWriter with a given label. More...
 
std::string ToString (void) const
 Write to a std::string. More...
 
void DWrite (void) const
 Write NameSet to console, debug version. More...
 
void DWrite (TokenWriter &tw) const
 Write to TokenWriter, debug version. More...
 
void Read (const std::string &rFileName, const std::string &rLabel="TimeConstraint")
 Read from file. More...
 
void Read (TokenReader &tr, const std::string &rLabel="TimeConstraint")
 Read from tokenreader. More...
 
std::string Name (void) const
 Return name of Constraint. More...
 
void Name (const std::string &rName)
 Set name of Constraint. More...
 
bool Empty (void) const
 Checks if TimeConstraint containts no ElemConstraints. More...
 
Idx Size (void) const
 Returns number of ElemConstraint s. More...
 
Iterator Insert (const ElemConstraint &rElemConstr)
 Adds an elementary clock constraint to the time constraint. More...
 
Iterator Insert (const std::string clockname, Operator op, const Time::Type timeconst)
 Adds an elementary clock constraint to the time constraint. More...
 
Iterator Insert (Idx clockindex, Operator op, const Time::Type timeconst)
 Adds an elementary clock constraint to the time constraint. More...
 
void Insert (const std::list< ElemConstraint > &rNewConstraints)
 Adds a list of elementary clock constraints to the time constraint. More...
 
void Insert (const TimeConstraint &rOtherTimeConstraint)
 Adds elementary clock constraints from other TimeConstant to the time constraint. More...
 
TimeConstraintoperator<< (const TimeConstraint &rOtherTimeConstraint)
 Convenience operator to combine a TimeConstraint with another TimeConstraint. More...
 
TimeConstraintoperator<< (const ElemConstraint &rElemConstr)
 Convenience operator to combines a TimeConstraint with an elementary TimeConstraint. More...
 
std::set< ElemConstraintClockConstraints (void) const
 Returns copy of ClockConstraints. More...
 
Idx InsClock (const std::string &rClockName) const
 Advertise clock to ClockSymbolTable and retrive index. More...
 
std::string ClockName (Idx clockindex) const
 Lookup clock name. More...
 
Idx ClockIndex (const std::string &rClockName) const
 Lookup clock index. More...
 
std::string EStr (const ElemConstraint &rElemConstr) const
 Pretty printable string of elem. More...
 
bool EraseByClock (Idx clock)
 Removes all elementary clock constraints refering to a specified clock. More...
 
Iterator Erase (Iterator it)
 Calls std::set::erase(iterator). More...
 
bool Erase (const ElemConstraint &rElemConstr)
 Removes elementary clock constraint. More...
 
bool Erase (const std::string &rClockName, Operator op, const Time::Type timeconst)
 Removes elementary clock constraint. More...
 
bool Erase (Idx clockindex, Operator op, const Time::Type timeconst)
 Removes elementary clock constraint. More...
 
void Clear (void)
 Clear all. More...
 
bool Exists (const ElemConstraint &rElemConstr) const
 Checks if elementary clock constraint is contained in constraint. More...
 
Iterator Begin (void) const
 Iterator to begin of set. More...
 
Iterator End (void) const
 Iterator to end of set. More...
 
RIterator RBegin (void) const
 Reverse iterator that yields the ElemConstraints in reverse order starting at the last element and ending after the first. More...
 
RIterator REnd (void) const
 Reverse iterator that yields the ElemConstraints in reverse order starting at the last element and ending after the first. More...
 
Iterator Begin (Idx clock) const
 Iterator to first constraint with specified clock. More...
 
Iterator End (Idx clock) const
 Iterator to first constraint just behind specified clock. More...
 
ClockSet ActiveClocks (void) const
 Returns a Clockset containing all clocks used by the TimeConstraint. More...
 
TimeInterval Interval (Idx clockindex) const
 Given a clock, compute the timeinterval in which the constraint is satisfied. More...
 
TimeInterval Interval (const std::string &clockname) const
 Given a clock, compute the timeinterval in which the constraint is satisfied. More...
 
void Interval (Idx clockindex, const TimeInterval &rInterval)
 Given a clock and an interval, set up the constraint such that it is valid in the given interval. More...
 
void Interval (const std::string &rClockName, const TimeInterval &rInterval)
 Given a clock and an interval, set up the constraint such that it is valid in the given interval. More...
 
void Minimize (void)
 Minimize by eliminating redundant elementary constraints. More...
 
bool operator== (const TimeConstraint &rOther) const
 Test for equality. More...
 
bool operator!= (const TimeConstraint &rOther) const
 Test for equality. More...
 

Protected Types

typedef std::set< ElemConstraint >::iterator iterator
 nonconst iterator to access ElemConstraints More...
 

Protected Attributes

std::string mName
 My name. More...
 
std::set< ElemConstraintmClockConstraints
 Set of elementary clock constraints. More...
 
SymbolTablempClockSymbolTable
 SymbolTable for clock names. More...
 

Member Typedef Documentation

◆ Iterator

typedef std::set<ElemConstraint>::const_iterator faudes::TimeConstraint::Iterator

Iterator to access ElemConstraints.

Definition at line 279 of file tp_timeconstraint.h.

◆ iterator

nonconst iterator to access ElemConstraints

Definition at line 805 of file tp_timeconstraint.h.

◆ Operator

Convenience typedef for operators.

Definition at line 285 of file tp_timeconstraint.h.

◆ RIterator

typedef std::set<ElemConstraint>::const_reverse_iterator faudes::TimeConstraint::RIterator

Reverse iterator to access ElemConstraints.

Definition at line 282 of file tp_timeconstraint.h.

Constructor & Destructor Documentation

◆ TimeConstraint() [1/3]

faudes::TimeConstraint::TimeConstraint ( void  )

Construct an empty TimeConstraint (allways satisfied)

Definition at line 198 of file tp_timeconstraint.cpp.

◆ TimeConstraint() [2/3]

faudes::TimeConstraint::TimeConstraint ( const TimeConstraint rOtherTimeConstraint)

Copy constructor.

Parameters
rOtherTimeConstraintTime constraint to copy

Definition at line 212 of file tp_timeconstraint.cpp.

◆ TimeConstraint() [3/3]

faudes::TimeConstraint::TimeConstraint ( const std::string &  rFilename,
const std::string &  rLabel = "TimeConstraint" 
)

Constructor from file.

Uses Read() to scan a file for specified label to read the constraint.

Parameters
rFilenameFile to read
rLabelSection label for the set in the file.

Definition at line 205 of file tp_timeconstraint.cpp.

◆ ~TimeConstraint()

faudes::TimeConstraint::~TimeConstraint ( void  )

Destructor.

Definition at line 221 of file tp_timeconstraint.cpp.

Member Function Documentation

◆ ActiveClocks()

ClockSet faudes::TimeConstraint::ActiveClocks ( void  ) const

Returns a Clockset containing all clocks used by the TimeConstraint.

Returns
Clockset containing all clocks used by the TimeConstraint.

Definition at line 452 of file tp_timeconstraint.cpp.

◆ Begin() [1/2]

TimeConstraint::Iterator faudes::TimeConstraint::Begin ( Idx  clock) const

Iterator to first constraint with specified clock.

Returns
TimeConstraint::iterator

Definition at line 442 of file tp_timeconstraint.cpp.

◆ Begin() [2/2]

TimeConstraint::Iterator faudes::TimeConstraint::Begin ( void  ) const

Iterator to begin of set.

Returns
TimeConstraint::Iterator

Definition at line 421 of file tp_timeconstraint.cpp.

◆ Clear()

void faudes::TimeConstraint::Clear ( void  )

Clear all.

Definition at line 413 of file tp_timeconstraint.cpp.

◆ ClockConstraints()

std::set< ElemConstraint > faudes::TimeConstraint::ClockConstraints ( void  ) const

Returns copy of ClockConstraints.

Definition at line 337 of file tp_timeconstraint.cpp.

◆ ClockIndex()

Idx faudes::TimeConstraint::ClockIndex ( const std::string &  rClockName) const

Lookup clock index.

Parameters
rClockNameSymbolic name of clock
Returns
Index of clock

Definition at line 262 of file tp_timeconstraint.cpp.

◆ ClockName()

std::string faudes::TimeConstraint::ClockName ( Idx  clockindex) const

Lookup clock name.

Parameters
clockindexindex of clock
Returns
name of clock

Definition at line 257 of file tp_timeconstraint.cpp.

◆ ClockSymbolTablep() [1/2]

void faudes::TimeConstraint::ClockSymbolTablep ( SymbolTable pSymTab)

Set Pointer to mpClockSymbolTable.

Definition at line 230 of file tp_timeconstraint.cpp.

◆ ClockSymbolTablep() [2/2]

SymbolTable * faudes::TimeConstraint::ClockSymbolTablep ( void  ) const

Get Pointer to mpClockSymbolTable.

Returns
Pointer to mpClockSymbolTable

Definition at line 225 of file tp_timeconstraint.cpp.

◆ DWrite() [1/2]

void faudes::TimeConstraint::DWrite ( TokenWriter tw) const

Write to TokenWriter, debug version.

Parameters
twReference to TokenWriter
Exceptions
std::ios::failureThrown on i/o error.

Definition at line 632 of file tp_timeconstraint.cpp.

◆ DWrite() [2/2]

void faudes::TimeConstraint::DWrite ( void  ) const

Write NameSet to console, debug version.

Definition at line 626 of file tp_timeconstraint.cpp.

◆ Empty()

bool faudes::TimeConstraint::Empty ( void  ) const

Checks if TimeConstraint containts no ElemConstraints.

Returns
True if TimeConstraint is empty. Else false.

Definition at line 242 of file tp_timeconstraint.cpp.

◆ End() [1/2]

TimeConstraint::Iterator faudes::TimeConstraint::End ( Idx  clock) const

Iterator to first constraint just behind specified clock.

Returns
TimeConstraint::Iterator

Definition at line 447 of file tp_timeconstraint.cpp.

◆ End() [2/2]

TimeConstraint::Iterator faudes::TimeConstraint::End ( void  ) const

Iterator to end of set.

Returns
TimeConstraint::Iterator

Definition at line 427 of file tp_timeconstraint.cpp.

◆ Erase() [1/4]

bool faudes::TimeConstraint::Erase ( const ElemConstraint rElemConstr)

Removes elementary clock constraint.

Parameters
rElemConstrConstraint to be removed.
Returns
True, if constraint has been removed

Definition at line 372 of file tp_timeconstraint.cpp.

◆ Erase() [2/4]

bool faudes::TimeConstraint::Erase ( const std::string &  rClockName,
Operator  op,
const Time::Type  timeconst 
)

Removes elementary clock constraint.

Parameters
rClockNameClock
opOperator
timeconstTime constant
Returns
True, if constraint has been removed

Definition at line 393 of file tp_timeconstraint.cpp.

◆ Erase() [3/4]

bool faudes::TimeConstraint::Erase ( Idx  clockindex,
Operator  op,
const Time::Type  timeconst 
)

Removes elementary clock constraint.

Parameters
clockindexClock
opOperator
timeconstTime constant
Returns
True, if constraint has been removed

Definition at line 384 of file tp_timeconstraint.cpp.

◆ Erase() [4/4]

TimeConstraint::Iterator faudes::TimeConstraint::Erase ( Iterator  it)

Calls std::set::erase(iterator).

ElemConstraint refered by it is removed from constraint.

Parameters
itTimeConstraint::Iterator pointing to ElemConstraint that is removed.
Returns
Iterator pointing to next ElemConstraint.

Definition at line 361 of file tp_timeconstraint.cpp.

◆ EraseByClock()

bool faudes::TimeConstraint::EraseByClock ( Idx  clock)

Removes all elementary clock constraints refering to a specified clock.

Parameters
clockClock whos constraints are to be removed.
Returns
True, if constraints(s) have been erased

Definition at line 343 of file tp_timeconstraint.cpp.

◆ EStr()

std::string faudes::TimeConstraint::EStr ( const ElemConstraint rElemConstr) const

Pretty printable string of elem.

constraint

Parameters
rElemConstrref to elem constraint
Returns
output string

Definition at line 268 of file tp_timeconstraint.cpp.

◆ Exists()

bool faudes::TimeConstraint::Exists ( const ElemConstraint rElemConstr) const

Checks if elementary clock constraint is contained in constraint.

Parameters
rElemConstrelementary constraint

Definition at line 402 of file tp_timeconstraint.cpp.

◆ InsClock()

Idx faudes::TimeConstraint::InsClock ( const std::string &  rClockName) const

Advertise clock to ClockSymbolTable and retrive index.

Parameters
rClockNamesymbolic name of clock
Returns
index of clock

Definition at line 252 of file tp_timeconstraint.cpp.

◆ Insert() [1/5]

TimeConstraint::Iterator faudes::TimeConstraint::Insert ( const ElemConstraint rElemConstr)

Adds an elementary clock constraint to the time constraint.

Parameters
rElemConstrElementary clock constraint that is to be added to time constraint
Returns
iterator to new constraint

Definition at line 278 of file tp_timeconstraint.cpp.

◆ Insert() [2/5]

void faudes::TimeConstraint::Insert ( const std::list< ElemConstraint > &  rNewConstraints)

Adds a list of elementary clock constraints to the time constraint.

Parameters
rNewConstraintsSet of elementary clock constraints that is to be added to time constraint.

Definition at line 310 of file tp_timeconstraint.cpp.

◆ Insert() [3/5]

TimeConstraint::Iterator faudes::TimeConstraint::Insert ( const std::string  clockname,
Operator  op,
const Time::Type  timeconst 
)

Adds an elementary clock constraint to the time constraint.

Parameters
clocknameClock for new ElemConstraint
opOperator for new ElemConstraint
timeconstTime constant for new ElemConstraint
Returns
iterator to new constraint

Definition at line 298 of file tp_timeconstraint.cpp.

◆ Insert() [4/5]

void faudes::TimeConstraint::Insert ( const TimeConstraint rOtherTimeConstraint)

Adds elementary clock constraints from other TimeConstant to the time constraint.

Parameters
rOtherTimeConstraintTime constraint whos clock constraints are to be added to time constraint.

Definition at line 321 of file tp_timeconstraint.cpp.

◆ Insert() [5/5]

TimeConstraint::Iterator faudes::TimeConstraint::Insert ( Idx  clockindex,
Operator  op,
const Time::Type  timeconst 
)

Adds an elementary clock constraint to the time constraint.

Parameters
clockindexClock for new ElemConstraint
opOperator for new ElemConstraint
timeconstTime constant for new ElemConstraint
Returns
iterator to new constraint

Definition at line 289 of file tp_timeconstraint.cpp.

◆ Interval() [1/4]

TimeInterval faudes::TimeConstraint::Interval ( const std::string &  clockname) const

Given a clock, compute the timeinterval in which the constraint is satisfied.

Returns
TimeInterval

Definition at line 465 of file tp_timeconstraint.cpp.

◆ Interval() [2/4]

void faudes::TimeConstraint::Interval ( const std::string &  rClockName,
const TimeInterval rInterval 
)

Given a clock and an interval, set up the constraint such that it is valid in the given interval.


Parameters
rClockNamespecifies the clock
rIntervalreference to time interval

Definition at line 503 of file tp_timeconstraint.cpp.

◆ Interval() [3/4]

TimeInterval faudes::TimeConstraint::Interval ( Idx  clockindex) const

Given a clock, compute the timeinterval in which the constraint is satisfied.

Returns
TimeInterval

Definition at line 471 of file tp_timeconstraint.cpp.

◆ Interval() [4/4]

void faudes::TimeConstraint::Interval ( Idx  clockindex,
const TimeInterval rInterval 
)

Given a clock and an interval, set up the constraint such that it is valid in the given interval.


Parameters
clockindexspecifies the clock
rIntervalreference to time interval

Definition at line 509 of file tp_timeconstraint.cpp.

◆ Minimize()

void faudes::TimeConstraint::Minimize ( void  )

Minimize by eliminating redundant elementary constraints.

The current implemantation retrieves the time constraints as intervals per clock and then converts back to a time constraint.

Definition at line 536 of file tp_timeconstraint.cpp.

◆ Name() [1/2]

void faudes::TimeConstraint::Name ( const std::string &  rName)
inline

Set name of Constraint.

Parameters
rNameBaseSet name

Definition at line 448 of file tp_timeconstraint.h.

◆ Name() [2/2]

std::string faudes::TimeConstraint::Name ( void  ) const
inline

Return name of Constraint.

Returns
Name

Definition at line 440 of file tp_timeconstraint.h.

◆ operator!=()

bool faudes::TimeConstraint::operator!= ( const TimeConstraint rOther) const

Test for equality.

Parameters
rOtherConstraint to compare with.
Returns
True if not equal; see operator==.

Definition at line 558 of file tp_timeconstraint.cpp.

◆ operator<<() [1/2]

TimeConstraint& faudes::TimeConstraint::operator<< ( const ElemConstraint rElemConstr)
inline

Convenience operator to combines a TimeConstraint with an elementary TimeConstraint.

Parameters
rElemConstrextra elemtary constraint
Returns
TimeConstraint object containing all ElemConstraints of both TimeConstraints.

Definition at line 539 of file tp_timeconstraint.h.

◆ operator<<() [2/2]

TimeConstraint& faudes::TimeConstraint::operator<< ( const TimeConstraint rOtherTimeConstraint)
inline

Convenience operator to combine a TimeConstraint with another TimeConstraint.

Parameters
rOtherTimeConstraintother TimeConstraint
Returns
TimeConstraint object containing all ElemConstraints of both TimeConstraints.

Definition at line 528 of file tp_timeconstraint.h.

◆ operator==()

bool faudes::TimeConstraint::operator== ( const TimeConstraint rOther) const

Test for equality.

The implementation converts both constraints to intervals and then performs the comparison.

Parameters
rOtherConstraint to compare with.
Returns
True if constraints are semantically identical.

Definition at line 546 of file tp_timeconstraint.cpp.

◆ RBegin()

TimeConstraint::RIterator faudes::TimeConstraint::RBegin ( void  ) const

Reverse iterator that yields the ElemConstraints in reverse order starting at the last element and ending after the first.

See set<...>::rbegin(void). Returns the "End".

Returns
TimeConstraint::RIterator

Definition at line 432 of file tp_timeconstraint.cpp.

◆ Read() [1/2]

void faudes::TimeConstraint::Read ( const std::string &  rFileName,
const std::string &  rLabel = "TimeConstraint" 
)

Read from file.

Reads specified label by creating a tokenreader and calling read(tr)

Parameters
rFileNameFilename
rLabeltoken label to read from file
Exceptions
ExceptionIf opening/reading fails an Exception object is thrown (id 1, 50, 51, 56)

Definition at line 643 of file tp_timeconstraint.cpp.

◆ Read() [2/2]

void faudes::TimeConstraint::Read ( TokenReader tr,
const std::string &  rLabel = "TimeConstraint" 
)

Read from tokenreader.

Clears before. It is an error if the file contains an index

Parameters
trReference to tokenreader
rLabelLabel to read
Exceptions
std::ios::failureThrown on i/o error.

Definition at line 649 of file tp_timeconstraint.cpp.

◆ REnd()

TimeConstraint::RIterator faudes::TimeConstraint::REnd ( void  ) const

Reverse iterator that yields the ElemConstraints in reverse order starting at the last element and ending after the first.

See set<...>::rend(void). Returns the "Begin".

Returns
TimeConstraint::RIterator

Definition at line 437 of file tp_timeconstraint.cpp.

◆ Size()

Idx faudes::TimeConstraint::Size ( void  ) const

Returns number of ElemConstraint s.

Returns
Number of ElemConstraint s.

Definition at line 247 of file tp_timeconstraint.cpp.

◆ ToString()

std::string faudes::TimeConstraint::ToString ( void  ) const

Write to a std::string.

Returns
String containing all elements

Definition at line 618 of file tp_timeconstraint.cpp.

◆ Write() [1/4]

void faudes::TimeConstraint::Write ( const std::string &  rFileName,
const std::string &  rLabel = "TimeConstraint",
std::ios::openmode  openmode = std::ios::out|std::ios::trunc 
) const

Write to file with label (default: "TimeConstraint") and openmode (default: truncate file).

Parameters
rFileNameFilename
rLabelLabel for set in file
openmodestd::ios::openmode
Exceptions
ExceptionIf opening/writing fails an Exception object is thrown (id 2)

Definition at line 570 of file tp_timeconstraint.cpp.

◆ Write() [2/4]

void faudes::TimeConstraint::Write ( TokenWriter tw) const

Write to TokenWriter.

The name of the constraint is used as the label in the file.

Parameters
twReference to TokenWriter
Exceptions
std::ios::failure
Thrown on i/o error.

Definition at line 584 of file tp_timeconstraint.cpp.

◆ Write() [3/4]

void faudes::TimeConstraint::Write ( TokenWriter tw,
const std::string &  rLabel 
) const

Write to TokenWriter with a given label.

Parameters
twReference to TokenWriter
rLabelLabel for set in file
Exceptions
std::ios::failureThrown on i/o error.

Definition at line 590 of file tp_timeconstraint.cpp.

◆ Write() [4/4]

void faudes::TimeConstraint::Write ( void  ) const

Write to console.

Definition at line 564 of file tp_timeconstraint.cpp.

Member Data Documentation

◆ mClockConstraints

std::set<ElemConstraint> faudes::TimeConstraint::mClockConstraints
protected

Set of elementary clock constraints.

Definition at line 799 of file tp_timeconstraint.h.

◆ mName

std::string faudes::TimeConstraint::mName
protected

My name.

Definition at line 796 of file tp_timeconstraint.h.

◆ mpClockSymbolTable

SymbolTable* faudes::TimeConstraint::mpClockSymbolTable
protected

SymbolTable for clock names.

Definition at line 802 of file tp_timeconstraint.h.


The documentation for this class was generated from the following files:

libFAUDES 2.32f --- 2024.12.22 --- c++ api documentaion by doxygen