#include <cfl_baseset.h>

Classes

class  Iterator
 

Public Types

enum  DetachMode { SetOnly , AttrIncl }
 

Public Member Functions

 TBaseSet (void)
 
 TBaseSet (const TBaseSet &rOtherSet)
 
 TBaseSet (const std::string &rFilename, const std::string &rLabel="BaseSet")
 
virtual ~TBaseSet (void)
 
const std::string & Name (void) const
 
void Name (const std::string &rName)
 
virtual void Clear (void)
 
Idx Size (void) const
 
bool Empty (void) const
 
virtual std::string Str (const T &rElem) const
 
Iterator Begin (void) const
 
Iterator End (void) const
 
virtual bool Valid (const T &rElem) const
 
virtual bool Erase (const T &rElem)
 
virtual Iterator Erase (const Iterator &pos)
 
virtual void EraseSet (const TBaseSet &rOtherSet)
 
virtual void RestrictSet (const TBaseSet &rOtherSet)
 
virtual bool Disjoint (const TBaseSet &rOtherSet) const
 
virtual bool Insert (const T &rElem)
 
virtual Iterator Inject (const Iterator &pos, const T &rElem)
 
virtual void Inject (const T &rElem)
 
virtual void InsertSet (const TBaseSet &rOtherSet)
 
bool Exists (const T &rElem) const
 
Iterator Find (const T &rElem) const
 
TBaseSet operator+ (const TBaseSet &rOtherSet) const
 
TBaseSet operator- (const TBaseSet &rOtherSet) const
 
TBaseSet operator* (const TBaseSet &rOtherSet) const
 
bool operator<= (const TBaseSet &rOtherSet) const
 
bool operator>= (const TBaseSet &rOtherSet) const
 
bool operator< (const TBaseSet &rOtherSet) const
 
void DValid (const std::string &rMessage="") const
 
void Detach (DetachMode flag=AttrIncl) const
 
void Lock (void) const
 
virtual const AttributeVoidAttributeType (void) const
 
virtual bool AttributeTest (const Type &rAttr) const
 
virtual TBaseSetAssignWithoutAttributes (const TBaseSet &rSourceSet)
 
virtual void Attributes (const TBaseSet &rOtherSet)
 
Idx AttributesSize (void) const
 
void ClearAttributes (void)
 
bool EqualAttributes (const TBaseSet &rOtherSet) const
 
virtual AttributeVoidAttributep (const T &rElem)
 
virtual const AttributeVoidAttribute (const T &rElem) const
 
virtual void Attribute (const T &rElem, const Type &rAttr)
 
virtual void AttributeTry (const T &rElem, const Type &rAttr)
 
virtual void ClrAttribute (const T &rElem)
 
virtual void XElementTag (const std::string &rTag)
 
virtual const std::string & TypeName (void) const
 
virtual void TypeName (const std::string &rType)
 
Typeoperator= (const Type &rSrc)
 
bool operator== (const Type &rOther) const
 
bool operator!= (const Type &rOther) const
 
- Public Member Functions inherited from faudes::Type
 Type (void)
 
 Type (const Type &rType)
 
virtual ~Type (void)
 
virtual TypeNew (void) const
 
virtual TypeCopy (void) const
 
virtual const TypeCast (const Type *pOther) const
 
virtual TypeAssign (const Type &rSrc)
 
Typeoperator= (const Type &rSrc)
 
virtual bool Equal (const Type &rOther) const
 
bool operator== (const Type &rOther) const
 
bool operator!= (const Type &rOther) const
 
void Write (const Type *pContext=0) const
 
void Write (const std::string &pFileName, const std::string &rLabel="", const Type *pContext=0, std::ios::openmode openmode=std::ios::out|std::ios::trunc) const
 
void Write (const std::string &pFileName, std::ios::openmode openmode) const
 
void Write (TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const
 
virtual void XWrite (const std::string &pFileName, const std::string &rLabel="", const Type *pContext=0) const
 
void XWrite (const Type *pContext=0) const
 
void XWrite (TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const
 
std::string ToString (const std::string &rLabel="", const Type *pContext=0) const
 
std::string ToText (const std::string &rLabel="", const Type *pContext=0) const
 
void DWrite (const Type *pContext=0) const
 
void DWrite (const std::string &pFileName, const std::string &rLabel="", const Type *pContext=0, std::ios::openmode openmode=std::ios::out|std::ios::trunc) const
 
void DWrite (TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const
 
void SWrite (TokenWriter &rTw) const
 
void SWrite (void) const
 
std::string ToSText (void) const
 
void Read (const std::string &rFileName, const std::string &rLabel="", const Type *pContext=0)
 
void FromString (const std::string &rString, const std::string &rLabel="", const Type *pContext=0)
 
void Read (TokenReader &rTr, const std::string &rLabel="", const Type *pContext=0)
 

Protected Types

typedef std::set< T, Cmp >::iterator iterator
 
typedef std::set< T, Cmp >::const_iterator const_iterator
 
typedef std::map< T, AttributeVoid * >::iterator aiterator
 
typedef std::map< T, AttributeVoid * >::const_iterator const_aiterator
 

Protected Member Functions

virtual void DoWrite (TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const
 
virtual void DoDWrite (TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const
 
virtual void DoSWrite (TokenWriter &rTw) const
 
virtual void DoRead (TokenReader &rTr, const std::string &rLabel="", const Type *pContext=0)
 
void DoAssign (const TBaseSet &rSourceSet)
 
bool DoEqual (const TBaseSet &rOtherSet) const
 
void DoAttribute (const T &rElem, const Type *pAttr)
 
const AttributeVoidDoAttribute (const T &rElem) const
 
AttributeVoidDoAttributeExplicit (const T &rElem)
 
TBaseSet< T, Cmp >::Iterator ThisIterator (const typename std::set< T, Cmp >::const_iterator &sit) const
 
void RelinkClients (void)
 
void AttachClient (TBaseSet *pRef) const
 
void DetachClient (TBaseSet *pRef) const
 
void AttachIterator (Iterator *pFit) const
 
void DetachIterator (Iterator *pFit) const
 
virtual const TypeDefinitionTypeDefinitionp (void) const
 
virtual const std::string & XElementTag (void) const
 
- Protected Member Functions inherited from faudes::Type
void DoAssign (const Type &rSrc)
 
bool DoEqual (const Type &rOther) const
 
virtual void DoXWrite (TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const
 
virtual Token XBeginTag (const std::string &rLabel="", const std::string &rFallbackLabel="") const
 

Protected Attributes

std::string mMyName
 
std::set< T, Cmp > * pSet
 
std::set< T, Cmp > * mpSet
 
std::map< T, AttributeVoid * > * pAttributes
 
std::map< T, AttributeVoid * > * mpAttributes
 
TBaseSet< T, Cmp > * pHostSet
 
std::list< TBaseSet< T, Cmp > * >::iterator mClientRecord
 
std::list< TBaseSet< T, Cmp > * > * mpClients
 
bool mDetached
 
bool mLocked
 
std::set< Iterator * > mIterators
 
std::string mXElementTagDef
 

Static Protected Attributes

static std::set< T, Cmp > msEmptySet =std::set<T,Cmp>()
 
static std::map< T, AttributeVoid * > msEmptyAttributes =std::map<T,AttributeVoid*>()
 

Private Attributes

const TypeDefinitionpTypeDefinition
 
std::string mFaudesTypeName
 
std::string mXElementTag
 

Friends

template<class TP , class AP , class CP >
class TAttrMap
 

Detailed Description

template<class T, class Cmp = std::less<T>>
class faudes::TBaseSet< T, Cmp >

STL style set template. This class template is built on top of the STL set template. It provides essentials of the STL interface relevant to libFAUDES plus a deferred copy mechanism, aka copy-on-write. TBaseSet serves as a base class for all libFaudes containers:

The public functions of a TBaseSet provide the high-level api, with the intention to organize the deferred copy machanism in a transparent manner. Since STL iterators refer to a particular STL container, they become invalid when the internal container is copied. Therefor, TBaseSet tracks iterators and fixes them when the actual copy takes place. This introduces some runtime overhead, in particular when your application represents subsets as sets of iterators. You may use the public method Lock() to enforce a full copy and to prevent any further re-allocation.

Alternatively to the high-level api, a protected low-level api is provided with direct access to the internal STL set. When using this api, it is up to the derived class to ensure that the BaseSet gets detached from its refernces befor write operations can take place.

The virtual function TBaseSet<T>::Valid() is used to indicate whether a candidate element is valid as a set member. If the macro FAUDES_CHECKED is defined, the attempt to insert an invalid element triggers an exception (id 61). Invalid iterators throw an exception (id 62) when used as an argument to a BaseSet function.

The TBaseSet also hosts a container to associate an attribute with each set element. However, in the plain TBAseSey the attribute type is set to void and member methods only deal with attributes when this does not invilve too much overhead. To make effective use of attributes, one is meant to derive a class from TBaseSet that encodes the actual attribute type and that provides appropriate access methods. This is facilitated by the class TAttrMap.

Note on a boring technical detail: since STL sets are sorted, effectively all set iterators should be const. However, there is a minor issue whether or not the erase function should use a const iterator as argument. SGI derived STL implementations (as used on most GNU systems) avoid this issue by defining const and non-const iterators on sets as identical types. MS implementation (used in VS C++ by default, as of 2006) differ in this aspect. The class TBaseSet::Iterator hides the issue from the faudes API but it is still present internaly.

Definition at line 98 of file cfl_baseset.h.

Member Typedef Documentation

◆ aiterator

template<class T , class Cmp = std::less<T>>
typedef std::map<T,AttributeVoid*>::iterator faudes::TBaseSet< T, Cmp >::aiterator
protected

STL attribute iterator, non-const version

Definition at line 942 of file cfl_baseset.h.

◆ const_aiterator

template<class T , class Cmp = std::less<T>>
typedef std::map<T,AttributeVoid*>::const_iterator faudes::TBaseSet< T, Cmp >::const_aiterator
protected

STL attribute iterator, const version

Definition at line 945 of file cfl_baseset.h.

◆ const_iterator

template<class T , class Cmp = std::less<T>>
typedef std::set<T,Cmp>::const_iterator faudes::TBaseSet< T, Cmp >::const_iterator
protected

STL iterator, const version

Definition at line 928 of file cfl_baseset.h.

◆ iterator

template<class T , class Cmp = std::less<T>>
typedef std::set<T,Cmp>::iterator faudes::TBaseSet< T, Cmp >::iterator
protected

STL iterator, non-const version

Definition at line 925 of file cfl_baseset.h.

Member Enumeration Documentation

◆ DetachMode

template<class T , class Cmp = std::less<T>>
enum faudes::TBaseSet::DetachMode

Detach from extern storage (incl allocation and true copy)

Enumerator
SetOnly 
AttrIncl 

Definition at line 376 of file cfl_baseset.h.

Member Function Documentation

◆ AttributeTry()

template<class T , class Cmp = std::less<T>>
virtual void faudes::TBaseSet< T, Cmp >::AttributeTry ( const T &  rElem,
const Type rAttr 
)
inlinevirtual

Attribute access. This virtual function provides an interface for derived classes with attributes eg TaIndexSet. It is meant to try to set the attribute as specified if the type can be casted. Otherwise it does nothing.

Parameters
rElemElement of which the attribute is to be set
rAttrAttribute value to set.

Reimplemented in faudes::TaTransSet< Attr >, faudes::TaNameSet< Attr >, faudes::TaNameSet< faudes::AttributeFailureEvents >, faudes::TaNameSet< AttributeSimCondition >, faudes::TaNameSet< faudes::AttributeSignalEvent >, faudes::TaNameSet< faudes::AttributeSimplenetEvent >, faudes::TaNameSet< EventAttr >, faudes::TaNameSet< SimEventAttribute >, faudes::TaIndexSet< Attr >, faudes::TaIndexSet< StateAttr >, and faudes::TaIndexSet< faudes::DiagLabelSet >.

Definition at line 787 of file cfl_baseset.h.

◆ operator!=()

template<class T , class Cmp = std::less<T>>
bool faudes::Type::operator!=

Test equality of configuration data. See operator==(const Type&).

This method calls the virtual method DoEqual(). Re-implementation can be done via the convenience macros FAUDES_TYPE_DECLARATION and FAUDES_TYPE_IMPLEMENTATION.

Parameters
rOtherOther objevt to compare with.
Returns
True on mismatch.

Definition at line 391 of file cfl_types.cpp.

◆ operator=()

template<class T , class Cmp = std::less<T>>
Type & faudes::Type::operator=

Assign configurationdata from other object. Derived classes should implement the operator form for the assignment for each source type which allows for a non-trivial assignment. This includes the particular case were the source and destination types match exactly. In the latter case the DoAssign method should be invoked. In contrast to the Assign function, the operator form must not be reimplemented for missmatched source types: the operator form only accepts sensible source types. This allows for compiletime typeckecking. However, the downside is that when the type is not known at compiletime, configuration is not properly assigned.

Re-implementation can be done via the convenience macros FAUDES_TYPE_DECLARATION and FAUDES_TYPE_IMPLEMENTATION.

Parameters
rSrcSource to copy from
Returns
Reference to this object.

Definition at line 340 of file cfl_types.cpp.

◆ operator==()

template<class T , class Cmp = std::less<T>>
bool faudes::Type::operator==

Test equality of configuration data. The operator form of the equality test is only defined for matching types, no cast will be performed. Thus, the test will be optimistic if the type is not known at compiletime. The object name or id is not considered in the test.

This methoc calls the virtual method DoEqual(). Re-implementation can be done via the convenience macros FAUDES_TYPE_DECLARATION and FAUDES_TYPE_IMPLEMENTATION.

Parameters
rOtherOther object to compare with.
Returns
True on match.

Definition at line 375 of file cfl_types.cpp.

Friends And Related Function Documentation

◆ TAttrMap

template<class T , class Cmp = std::less<T>>
template<class TP , class AP , class CP >
friend class TAttrMap
friend

allow access to attribute interface class

Definition at line 109 of file cfl_baseset.h.

Member Data Documentation

◆ mClientRecord

template<class T , class Cmp = std::less<T>>
std::list< TBaseSet<T,Cmp>* >::iterator faudes::TBaseSet< T, Cmp >::mClientRecord
protected

Iterator to the client list that hosts our data (maintained by host)

Definition at line 954 of file cfl_baseset.h.

◆ mDetached

template<class T , class Cmp = std::less<T>>
bool faudes::TBaseSet< T, Cmp >::mDetached
protected

Indicate "hosts data to myself only"

Definition at line 960 of file cfl_baseset.h.

◆ mFaudesTypeName

template<class T , class Cmp = std::less<T>>
std::string faudes::TBaseSet< T, Cmp >::mFaudesTypeName
private

Current/cached faudes type-name

Definition at line 1006 of file cfl_baseset.h.

◆ mIterators

template<class T , class Cmp = std::less<T>>
std::set< Iterator* > faudes::TBaseSet< T, Cmp >::mIterators
protected

Iterators that refer to this TBaseSet

Definition at line 975 of file cfl_baseset.h.

◆ mLocked

template<class T , class Cmp = std::less<T>>
bool faudes::TBaseSet< T, Cmp >::mLocked
protected

Indicate "dont re-allocate the STL set ever again"

Definition at line 963 of file cfl_baseset.h.

◆ mMyName

template<class T , class Cmp = std::less<T>>
std::string faudes::TBaseSet< T, Cmp >::mMyName
protected

Name of this BaseSet

Definition at line 916 of file cfl_baseset.h.

◆ mpAttributes

template<class T , class Cmp = std::less<T>>
std::map<T,AttributeVoid*>* faudes::TBaseSet< T, Cmp >::mpAttributes
protected

Attribute map, if this object hosts data (else NULL).

Definition at line 939 of file cfl_baseset.h.

◆ mpClients

template<class T , class Cmp = std::less<T>>
std::list< TBaseSet<T,Cmp>* >* faudes::TBaseSet< T, Cmp >::mpClients
protected

BaseSets, that use data hosted by us (NULL if we dont host data, emptyset if we host to ourself excl.)

Definition at line 957 of file cfl_baseset.h.

◆ mpSet

template<class T , class Cmp = std::less<T>>
std::set<T,Cmp>* faudes::TBaseSet< T, Cmp >::mpSet
protected

STL set, if this object hosts data (else NULL)

Definition at line 922 of file cfl_baseset.h.

◆ mXElementTag

template<class T , class Cmp = std::less<T>>
std::string faudes::TBaseSet< T, Cmp >::mXElementTag
private

Current/cached name of elements (use protected accessor methods for caching)

Definition at line 1009 of file cfl_baseset.h.

◆ mXElementTagDef

template<class T , class Cmp = std::less<T>>
std::string faudes::TBaseSet< T, Cmp >::mXElementTagDef
protected

Defauft name of elements (if not over written by registry)

Definition at line 1014 of file cfl_baseset.h.

◆ pAttributes

template<class T , class Cmp = std::less<T>>
std::map<T,AttributeVoid*>* faudes::TBaseSet< T, Cmp >::pAttributes
protected

Pointer to attribute map to operate on

Definition at line 936 of file cfl_baseset.h.

◆ pHostSet

template<class T , class Cmp = std::less<T>>
TBaseSet<T,Cmp>* faudes::TBaseSet< T, Cmp >::pHostSet
protected

Pointer on BaseSet that hosts our data (THIS if we host)

Definition at line 951 of file cfl_baseset.h.

◆ pSet

template<class T , class Cmp = std::less<T>>
std::set<T,Cmp>* faudes::TBaseSet< T, Cmp >::pSet
protected

Pointer on STL set to operate on

Definition at line 919 of file cfl_baseset.h.

◆ pTypeDefinition

template<class T , class Cmp = std::less<T>>
const TypeDefinition* faudes::TBaseSet< T, Cmp >::pTypeDefinition
private

static empty STL client list TypeDefinition cache (should use guarded pointer here)

Definition at line 1003 of file cfl_baseset.h.


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

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