STL style set template. More...

#include <cfl_baseset.h>

Classes

class  Iterator
 Iterator class for high-level api to TBaseSet. More...

Public Types

enum  DetachMode { SetOnly, AttrIncl }
 Detach from extern storage (incl allocation and true copy) More...

Public Member Functions

 TBaseSet (void)
 Constructor.
 TBaseSet (const TBaseSet &rOtherSet)
 Copy-constructor.
 TBaseSet (const std::string &rFilename, const std::string &rLabel="BaseSet")
 Constructor from file.
virtual ~TBaseSet (void)
 Virtual destructor.
const std::string & Name (void) const
 Return name of TBaseSet.
void Name (const std::string &rName)
 Set name of TBaseSet.
virtual void Clear (void)
 Clear all set.
Idx Size (void) const
 Get Size of TBaseSet.
bool Empty (void) const
 Test whether if the TBaseSet is Empty.
virtual std::string Str (const T &rElem) const
 Return pretty printable element.
Iterator Begin (void) const
 Iterator to the begin of set.
Iterator End (void) const
 Iterator to the end of set.
virtual bool Valid (const T &rElem) const
 Test validty of candidate element.
virtual bool Erase (const T &rElem)
 Erase element by reference.
virtual Iterator Erase (const Iterator &pos)
 Erase element by iterator.
virtual void EraseSet (const TBaseSet &rOtherSet)
 Erase elements given by other set.
virtual void RestrictSet (const TBaseSet &rOtherSet)
 Restrict elements given by other set.
virtual bool Insert (const T &rElem)
 Insert specified element.
virtual Iterator Inject (const Iterator &pos, const T &rElem)
 Insert specified element.
virtual void Inject (const T &rElem)
 Insert specified element.
virtual void InsertSet (const TBaseSet &rOtherSet)
 Insert elements given by rOtherSet.
bool Exists (const T &rElem) const
 Test existence of element.
Iterator Find (const T &rElem) const
 Find element and return iterator.
TBaseSet operator+ (const TBaseSet &rOtherSet) const
 Set union operator.
TBaseSet operator- (const TBaseSet &rOtherSet) const
 Set difference operator.
TBaseSet operator* (const TBaseSet &rOtherSet) const
 Set intersection operator.
bool operator<= (const TBaseSet &rOtherSet) const
 Test for subset.
bool operator>= (const TBaseSet &rOtherSet) const
 Test for superset.
bool operator< (const TBaseSet &rOtherSet) const
 Order for sorting containers of TBaseSet.
void DValid (const std::string &rMessage="") const
 Some validation of deferred copy mechanism (provoke abort)
void Detach (DetachMode flag=AttrIncl) const
void Lock (void) const
 Detach and lock any further reallocation.
virtual const AttributeVoidAttributeType (void) const
 Attribute typeinfo.
virtual bool AttributeTest (const Type &rAttr) const
 Attribute typeinfo.
virtual TBaseSetAssignWithoutAttributes (const TBaseSet &rSourceSet)
 Attribute access.
virtual void Attributes (const TBaseSet &rOtherSet)
 Attributes access.
Idx AttributesSize (void) const
 Attribute access.
void ClearAttributes (void)
 Attribute access.
bool EqualAttributes (const TBaseSet &rOtherSet) const
 Attribute access.
virtual AttributeVoidAttributep (const T &rElem)
 Attribute access.
virtual const AttributeVoidAttribute (const T &rElem) const
 Attribute access.
virtual void Attribute (const T &rElem, const Type &rAttr)
 Attribute access.
virtual void AttributeTry (const T &rElem, const Type &rAttr)
 Attribute access.
virtual void ClrAttribute (const T &rElem)
 Attribute access.
virtual void XElementTag (const std::string &rTag)
 Configure the element name tag.
virtual const std::string & TypeName (void) const
 Get objects's type name.
virtual void TypeName (const std::string &rType)
 Overwrite faudes-type name.
- Public Member Functions inherited from faudes::Type
 Type (void)
 Constructor.
 Type (const Type &rType)
 Copy constructor.
virtual ~Type (void)
 Destructor.
virtual TypeNew (void) const
 Construct on heap.
virtual TypeCopy (void) const
 Construct on heap.
virtual const TypeCast (const Type *pOther) const
 Cast other object to this type.
virtual TypeAssign (const Type &rSrc)
 Assign configuration data from other object.
virtual Typeoperator= (const Type &rSrc)
 Assign configurationdata from other object.
virtual bool Equal (const Type &rOther) const
 Test equality of configuration data.
virtual bool operator== (const Type &rOther) const
 Test equality of configuration data.
virtual bool operator!= (const Type &rOther) const
 Test equality of configuration data.
void Write (const Type *pContext=0) const
 Write configuration data to console.
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
 Write configuration data to a file.
void Write (const std::string &pFileName, std::ios::openmode openmode) const
 Write configuration data to a file.
void Write (TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const
 Write configuration data to TokenWriter.
virtual void XWrite (const std::string &pFileName, const std::string &rLabel="", const Type *pContext=0) const
 Write configuration data to an XML file.
void XWrite (const Type *pContext=0) const
 Write configuration data in XML format to concole Note: this write function uses the virtual function DoXWrite(), to be reimplemented by derived classes.
void XWrite (TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const
 Write configuration data in XML format to TokenWriter.
std::string ToString (const std::string &rLabel="", const Type *pContext=0) const
 Write configuration data to a string.
std::string ToText (const std::string &rLabel="", const Type *pContext=0) const
 Write configuration data to a formated string.
void DWrite (const Type *pContext=0) const
 Write configuration data to console, debugging format.
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
 Write configuration data to a file, debugging format.
void DWrite (TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const
 Write configuration data in debug format to TokenWriter.
void SWrite (TokenWriter &rTw) const
 Write statistics comment to TokenWriter.
void SWrite (void) const
 Write statistics comment to console.
std::string ToSText (void) const
 Write statistics to a string.
void Read (const std::string &rFileName, const std::string &rLabel="", const Type *pContext=0)
 Read configuration data from file with label specified.
void FromString (const std::string &rString, const std::string &rLabel="", const Type *pContext=0)
 Read configuration data from a string.
void Read (TokenReader &rTr, const std::string &rLabel="", const Type *pContext=0)
 Read configuration data from TokenReader with label sepcified.

Protected Types

typedef std::set< T, Cmp >
::iterator 
iterator
 STL iterator, non-const version.
typedef std::set< T, Cmp >
::const_iterator 
const_iterator
 STL iterator, const version.
typedef std::map< T,
AttributeVoid * >::iterator 
aiterator
 STL attribute iterator, non-const version.
typedef std::map< T,
AttributeVoid * >
::const_iterator 
const_aiterator
 STL attribute iterator, const version.

Protected Member Functions

virtual void DoWrite (TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const
 Token output, see Type::DWrite for public wrappers.
virtual void DoDWrite (TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const
 Token output, debugging see Type::DWrite for public wrappers.
virtual void DoSWrite (TokenWriter &rTw) const
 Token output, see Type::SWrite for public wrappers.
virtual void DoRead (TokenReader &rTr, const std::string &rLabel="", const Type *pContext=0)
 Token input, see Type::Read for public wrappers.
void DoAssign (const TBaseSet &rSourceSet)
 assign my members
bool DoEqual (const TBaseSet &rOtherSet) const
 test equality
void DoAttribute (const T &rElem, const Type *pAttr)
 set attribute in map (assume elem exists in set, NULL <=> set to default)
const AttributeVoidDoAttribute (const T &rElem) const
 get attribute from map (return null if elem does not exist in map)
AttributeVoidDoAttributeExplicit (const T &rElem)
 get attribute from map (insert explicit default if elem does not exist in map)
TBaseSet< T, Cmp >::Iterator ThisIterator (const typename std::set< T, Cmp >::const_iterator &sit) const
 Convert STL iterator to API iterator.
void RelinkClients (void)
 Ensure that we do not host contents to anyone else.
void AttachClient (TBaseSet *pRef) const
 Record that we provide contents to some other BaseSet.
void DetachClient (TBaseSet *pRef) const
 Record that we stop providing data for some TBaseSet.
void AttachIterator (Iterator *pFit) const
 Record that an iterator refers to this TBaseSet.
void DetachIterator (Iterator *pFit) const
 Record that an iterator stops to refer to this TBaseSet.
virtual const TypeDefinitionTypeDefinitionp (void) const
 Reimplment from type to use chache.
virtual const std::string & XElementTag (void) const
 Get name of elements (used for XML IO)
- Protected Member Functions inherited from faudes::Type
void DoAssign (const Type &rSrc)
 Assign configuration data from other object.
bool DoEqual (const Type &rOther) const
 Test equality of configuration data.
virtual void DoXWrite (TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const
 Write configuration data of this object to TokenWriter in XML format.
virtual Token XBeginTag (const std::string &rLabel="", const std::string &rFallbackLabel="") const

Protected Attributes

std::string mMyName
 Name of this BaseSet.
std::set< T, Cmp > * pSet
 Pointer on STL set to operate on.
std::set< T, Cmp > * mpSet
 STL set, if this object hosts data (else NULL)
std::map< T, AttributeVoid * > * pAttributes
 Pointer to attribute map to operate on.
std::map< T, AttributeVoid * > * mpAttributes
 Attribute map, if this object hosts data (else NULL).
TBaseSet< T, Cmp > * pHostSet
 Pointer on BaseSet that hosts our data (THIS if we host)
std::list< TBaseSet< T, Cmp >
* >::iterator 
mClientRecord
 Iterator to the client list that hosts our data (maintained by host)
std::list< TBaseSet< T, Cmp > * > * mpClients
 BaseSets, that use data hosted by us (NULL if we dont host data, emptyset if we host to ourself excl.)
bool mDetached
 Indicate "hosts data to myself only".
bool mLocked
 Indicate "dont re-allocate the STL set ever again".
std::set< Iterator * > mIterators
 Iterators that refer to this TBaseSet.

Static Protected Attributes

static std::set< T, Cmp > msEmptySet = std::set<T,Cmp>()
 static empty STL set for default constructor
static std::map< T,
AttributeVoid * > 
msEmptyAttributes = std::map<T,AttributeVoid*>()
 static empty STL map for default constructor

Private Attributes

const TypeDefinitionpTypeDefinition
 static empty STL client list
std::string mXElementTag
 Current/cached name of elements (used protected accessor method)
std::string mFaudesTypeName
 Current/cached faudes type-name.

Friends

class TAttrMap
 allow access to attribute interface class

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 93 of file cfl_baseset.h.

Member Typedef Documentation

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 926 of file cfl_baseset.h.

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 929 of file cfl_baseset.h.

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 912 of file cfl_baseset.h.

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 909 of file cfl_baseset.h.

Member Enumeration Documentation

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 360 of file cfl_baseset.h.

Constructor & Destructor Documentation

template<class T , class Cmp >
faudes::TBaseSet< T, Cmp >::TBaseSet ( void  )

Constructor.

Definition at line 1169 of file cfl_baseset.h.

template<class T , class Cmp >
faudes::TBaseSet< T, Cmp >::TBaseSet ( const TBaseSet< T, Cmp > &  rOtherSet)

Copy-constructor.

Parameters
rOtherSetSource to copy from

Definition at line 1209 of file cfl_baseset.h.

template<class T , class Cmp >
faudes::TBaseSet< T, Cmp >::TBaseSet ( const std::string &  rFilename,
const std::string &  rLabel = "BaseSet" 
)

Constructor from file.

This constructor indicates the intended interface for derived classes. The base set itself cannot read from token streams.

Parameters
rFilenameName of File
rLabelSection for the set in the file;

Definition at line 1188 of file cfl_baseset.h.

template<class T , class Cmp >
faudes::TBaseSet< T, Cmp >::~TBaseSet ( void  )
virtual

Virtual destructor.

Definition at line 1231 of file cfl_baseset.h.

Member Function Documentation

template<class T , class Cmp >
TBaseSet< T, Cmp > & faudes::TBaseSet< T, Cmp >::AssignWithoutAttributes ( const TBaseSet< T, Cmp > &  rSourceSet)
virtual

Attribute access.

This virtual function provides an interface for derived classes with attributes eg TaIndexSet. The current implementation uses the DoAssign method and clears any attributes afterwards. Future implementations may be more efficient.

Parameters
rSourceSetSet to copy from

Definition at line 2210 of file cfl_baseset.h.

template<class T , class Cmp >
void faudes::TBaseSet< T, Cmp >::AttachClient ( TBaseSet< T, Cmp > *  pRef) const
inlineprotected

Record that we provide contents to some other BaseSet.

Definition at line 1536 of file cfl_baseset.h.

template<class T , class Cmp >
void faudes::TBaseSet< T, Cmp >::AttachIterator ( Iterator pFit) const
inlineprotected

Record that an iterator refers to this TBaseSet.

Definition at line 1586 of file cfl_baseset.h.

template<class T, class Cmp >
const AttributeVoid & faudes::TBaseSet< T, Cmp >::Attribute ( const T &  rElem) const
virtual

Attribute access.

This virtual function provides an interface for derived classes with attributes eg TaIndexSet. The TBaseSet has no attributes and thus returns a void attribute. Derived classes that provide attributes are meant to return the attribute specified by rElem.

Parameters
rElemElement of which the attribute is requested
Returns
Attribute of specified element

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

Definition at line 2263 of file cfl_baseset.h.

template<class T, class Cmp >
void faudes::TBaseSet< T, Cmp >::Attribute ( const T &  rElem,
const Type rAttr 
)
virtual

Attribute access.

This virtual function provides an interface for derived classes with attributes eg TaIndexSet. The TBaseSet itself has void attributes and thus formally accepts any nontrivial attribute, however, ignoring any value. Derived classes that provide attributes are meant to set the attribute as specified. Only if the required cast to the actual attribute type fails an exception is thrown.

Parameters
rElemElement of which the attribute is to be set
rAttrAttribute value to set.
Exceptions
Exception
  • Element does not exist (60)
  • Cannot cast attribute type (63)

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

Definition at line 2270 of file cfl_baseset.h.

template<class T, class Cmp >
AttributeVoid * faudes::TBaseSet< T, Cmp >::Attributep ( const T &  rElem)
virtual

Attribute access.

This virtual function provides an interface for derived classes with attributes eg TaIndexSet. The TBaseSet has no attributes and thus throws an exception. Derived classes that provide attributes are meant to return a pointer to the attribute specified by rElem.

Parameters
rElemElement of which the attribute is requested
Returns
Attribute of specified element
Exceptions
Exception
  • No attributes provided (id 63)

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

Definition at line 2252 of file cfl_baseset.h.

template<class T , class Cmp >
void faudes::TBaseSet< T, Cmp >::Attributes ( const TBaseSet< T, Cmp > &  rOtherSet)
virtual

Attributes access.

This virtual function provides an interface for derived classes with attributes eg TaIndexSet. It copies attributes from the specified set, provided that they can be casted appropriately. Elements of this set which are not in rOtherSet maintain their attribute.

Parameters
rOtherSetOther BaseSet
Exceptions
Exception
  • Cannot cast attribute type (63)

Definition at line 2219 of file cfl_baseset.h.

template<class T , class Cmp >
Idx faudes::TBaseSet< T, Cmp >::AttributesSize ( void  ) const

Attribute access.

This virtual function provides an interface for derived classes with attributes eg TaIndexSet. Provide the number of explicit attributes. The TBaseSet itself has no attributes and thus this function returns 0.

Definition at line 2155 of file cfl_baseset.h.

template<class T , class Cmp >
bool faudes::TBaseSet< T, Cmp >::AttributeTest ( const Type rAttr) const
virtual

Attribute typeinfo.

This virtual function provides an interface for derived classes with attributes eg TaIndexSet. It tests whether this set accepts the specified attribute type ie whether it can be casted. The test is performned by the Cast function of the attribute type returned by AttributeType().

Parameters
rAttrAttribute type to test.
Returns
True, if attribute type is accepted.

Definition at line 2150 of file cfl_baseset.h.

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< AttributeSimCondition >, faudes::TaNameSet< EventAttr >, faudes::TaNameSet< AttributeSignalEvent >, faudes::TaNameSet< SimEventAttribute >, faudes::TaNameSet< AttributeSimplenetEvent >, faudes::TaIndexSet< Attr >, and faudes::TaIndexSet< StateAttr >.

Definition at line 771 of file cfl_baseset.h.

template<class T , class Cmp >
const AttributeVoid * faudes::TBaseSet< T, Cmp >::AttributeType ( void  ) const
virtual

Attribute typeinfo.

This virtual function provides an interface for derived container classes with attributes eg TaIndexSet. When not re-implemented, it returns an attribute with type AttributeVoid to indicate the absence of nontrivial attributes

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

Definition at line 2144 of file cfl_baseset.h.

template<class T , class Cmp >
TBaseSet< T, Cmp >::Iterator faudes::TBaseSet< T, Cmp >::Begin ( void  ) const
inline

Iterator to the begin of set.

Returns
Iterator

Reimplemented in faudes::TTransSet< Cmp >, and faudes::TTransSet< TransSort::X1EvX2 >.

Definition at line 1885 of file cfl_baseset.h.

template<class T , class Cmp >
void faudes::TBaseSet< T, Cmp >::Clear ( void  )
virtual

Clear all set.

Reimplemented from faudes::Type.

Definition at line 1896 of file cfl_baseset.h.

template<class T , class Cmp >
void faudes::TBaseSet< T, Cmp >::ClearAttributes ( void  )

Attribute access.

This virtual function provides an interface for derived classes with attributes eg TaIndexSet. The TBaseSet itself has no attributes and thus this function does nothing.

Definition at line 2160 of file cfl_baseset.h.

template<class T, class Cmp >
void faudes::TBaseSet< T, Cmp >::ClrAttribute ( const T &  rElem)
virtual

Attribute access.

Cleras an explicit attribute associated with the specified element if sucht attribute exists. The TBaseSet itself has no attributes and thus this function will do nothing.

Parameters
rElemElement of which the attribute is to be cleared

Definition at line 2290 of file cfl_baseset.h.

template<class T , class Cmp >
void faudes::TBaseSet< T, Cmp >::Detach ( DetachMode  flag = AttrIncl) const

Definition at line 1325 of file cfl_baseset.h.

template<class T , class Cmp >
void faudes::TBaseSet< T, Cmp >::DetachClient ( TBaseSet< T, Cmp > *  pRef) const
inlineprotected

Record that we stop providing data for some TBaseSet.

Definition at line 1544 of file cfl_baseset.h.

template<class T , class Cmp >
void faudes::TBaseSet< T, Cmp >::DetachIterator ( Iterator pFit) const
inlineprotected

Record that an iterator stops to refer to this TBaseSet.

Definition at line 1593 of file cfl_baseset.h.

template<class T , class Cmp >
void faudes::TBaseSet< T, Cmp >::DoAssign ( const TBaseSet< T, Cmp > &  rSourceSet)
protected

assign my members

Definition at line 1255 of file cfl_baseset.h.

template<class T, class Cmp >
void faudes::TBaseSet< T, Cmp >::DoAttribute ( const T &  rElem,
const Type pAttr 
)
protected

set attribute in map (assume elem exists in set, NULL <=> set to default)

Definition at line 2325 of file cfl_baseset.h.

template<class T, class Cmp >
const AttributeVoid * faudes::TBaseSet< T, Cmp >::DoAttribute ( const T &  rElem) const
protected

get attribute from map (return null if elem does not exist in map)

Definition at line 2297 of file cfl_baseset.h.

template<class T, class Cmp >
AttributeVoid * faudes::TBaseSet< T, Cmp >::DoAttributeExplicit ( const T &  rElem)
protected

get attribute from map (insert explicit default if elem does not exist in map)

Definition at line 2305 of file cfl_baseset.h.

template<class T , class Cmp >
void faudes::TBaseSet< T, Cmp >::DoDWrite ( TokenWriter rTw,
const std::string &  rLabel = "",
const Type pContext = 0 
) const
protectedvirtual

Token output, debugging see Type::DWrite for public wrappers.

Reimplement this function in derived classes for specific specific template parameters.

Parameters
rTwReference to TokenWriter
rLabelLabel of section to write, defaults to name of set
pContextWrite context to provide contextual information

Reimplemented from faudes::Type.

Reimplemented in faudes::NameSet.

Definition at line 1836 of file cfl_baseset.h.

template<class T , class Cmp >
bool faudes::TBaseSet< T, Cmp >::DoEqual ( const TBaseSet< T, Cmp > &  rOtherSet) const
protected

test equality

Definition at line 2117 of file cfl_baseset.h.

template<class T , class Cmp >
void faudes::TBaseSet< T, Cmp >::DoRead ( TokenReader rTr,
const std::string &  rLabel = "",
const Type pContext = 0 
)
protectedvirtual

Token input, see Type::Read for public wrappers.

Reimplement this function in derived classes for specific specific template parameters. By convention, the default label "" should be translated to some meaningful default, eg "IndexSet" for a set of indices". The pContext pointer can de type-checked and interpreted, ie as a symboltable to provide symbolic names. It is also passed on to attributes.

Parameters
rTrReference to TokenReader
rLabelLabel of section to read, defaults to name of set
pContextRead context to provide contextual information

Reimplemented from faudes::Type.

Reimplemented in faudes::NameSet, faudes::IndexSet, and faudes::SymbolSet.

Definition at line 1869 of file cfl_baseset.h.

template<class T , class Cmp >
void faudes::TBaseSet< T, Cmp >::DoSWrite ( TokenWriter rTw) const
protectedvirtual

Token output, see Type::SWrite for public wrappers.

Statistics include size, name and attributey type. The latter is retrieved from the RTI, if initialized. Dereived sets may reimplement this method.

Parameters
rTwReference to TokenWriter

Reimplemented from faudes::Type.

Definition at line 1854 of file cfl_baseset.h.

template<class T , class Cmp >
void faudes::TBaseSet< T, Cmp >::DoWrite ( TokenWriter rTw,
const std::string &  rLabel = "",
const Type pContext = 0 
) const
protectedvirtual

Token output, see Type::DWrite for public wrappers.

Reimplement this function in derived classes for specific specific template parameters. By convention, the default label "" should be translated to a) the name of the set or b) some meaningful default, eg "IndexSet" for a set of indices. The pContext pointer can de type-checked and interpreted, ie as a symboltable to provide symbolic names. It is also passed on to attributes.

Parameters
rTwReference to TokenWriter
rLabelLabel of section to write, defaults to name of set
pContextWrite context to provide contextual information

Reimplemented from faudes::Type.

Reimplemented in faudes::TTransSet< Cmp >, faudes::TTransSet< TransSort::X1EvX2 >, faudes::NameSet, faudes::IndexSet, and faudes::SymbolSet.

Definition at line 1824 of file cfl_baseset.h.

template<class T , class Cmp >
void faudes::TBaseSet< T, Cmp >::DValid ( const std::string &  rMessage = "") const

Some validation of deferred copy mechanism (provoke abort)

Definition at line 1600 of file cfl_baseset.h.

template<class T , class Cmp >
bool faudes::TBaseSet< T, Cmp >::Empty ( void  ) const

Test whether if the TBaseSet is Empty.

Returns
True if empty

Definition at line 1818 of file cfl_baseset.h.

template<class T , class Cmp >
TBaseSet< T, Cmp >::Iterator faudes::TBaseSet< T, Cmp >::End ( void  ) const
inline

Iterator to the end of set.

Returns
Iterator

Reimplemented in faudes::TTransSet< Cmp >, and faudes::TTransSet< TransSort::X1EvX2 >.

Definition at line 1890 of file cfl_baseset.h.

template<class T , class Cmp >
bool faudes::TBaseSet< T, Cmp >::EqualAttributes ( const TBaseSet< T, Cmp > &  rOtherSet) const

Attribute access.

Test whether attributes match with other set, and return true if attributes match for shared elements. It uses the equality test of individual attributes and, hence, requires the attribute type match too.

Parameters
rOtherSetOther set to compare with.
Returns
True on match.

Definition at line 2169 of file cfl_baseset.h.

template<class T, class Cmp >
TBaseSet< T, Cmp >::Iterator faudes::TBaseSet< T, Cmp >::Erase ( const Iterator pos)
virtual
template<class T , class Cmp >
void faudes::TBaseSet< T, Cmp >::EraseSet ( const TBaseSet< T, Cmp > &  rOtherSet)
virtual

Erase elements given by other set.

Parameters
rOtherSetSet of elements to erase

Definition at line 2036 of file cfl_baseset.h.

template<class T, class Cmp >
bool faudes::TBaseSet< T, Cmp >::Exists ( const T &  rElem) const

Test existence of element.

Parameters
rElemElement to test
Returns
True if element exists in set

Reimplemented in faudes::TTransSet< Cmp >, faudes::TTransSet< TransSort::X1EvX2 >, and faudes::NameSet.

Definition at line 2088 of file cfl_baseset.h.

template<class T, class Cmp >
TBaseSet< T, Cmp >::Iterator faudes::TBaseSet< T, Cmp >::Find ( const T &  rElem) const

Find element and return iterator.

Parameters
rElemElement to find
Returns
Iterator to element or End() if nonexistent

Reimplemented in faudes::TTransSet< Cmp >, faudes::TTransSet< TransSort::X1EvX2 >, and faudes::NameSet.

Definition at line 2083 of file cfl_baseset.h.

template<class T, class Cmp >
TBaseSet< T, Cmp >::Iterator faudes::TBaseSet< T, Cmp >::Inject ( const Iterator pos,
const T &  rElem 
)
virtual

Insert specified element.

Parameters
posInsertion hint passed to STL
rElemElement to insert
Returns
Insertion position

Definition at line 1967 of file cfl_baseset.h.

template<class T, class Cmp >
void faudes::TBaseSet< T, Cmp >::Inject ( const T &  rElem)
virtual

Insert specified element.

Parameters
rElemElement to insert

Reimplemented in faudes::TTransSet< Cmp >, and faudes::TTransSet< TransSort::X1EvX2 >.

Definition at line 1975 of file cfl_baseset.h.

template<class T , class Cmp >
void faudes::TBaseSet< T, Cmp >::InsertSet ( const TBaseSet< T, Cmp > &  rOtherSet)
virtual

Insert elements given by rOtherSet.

Parameters
rOtherSetSet of elements to insert

Definition at line 1981 of file cfl_baseset.h.

template<class T , class Cmp >
void faudes::TBaseSet< T, Cmp >::Lock ( void  ) const

Detach and lock any further reallocation.

Definition at line 1456 of file cfl_baseset.h.

template<class T , class Cmp >
const std::string & faudes::TBaseSet< T, Cmp >::Name ( void  ) const
virtual

Return name of TBaseSet.

Returns
Name of TBaseSet

Reimplemented from faudes::Type.

Definition at line 1749 of file cfl_baseset.h.

template<class T , class Cmp >
void faudes::TBaseSet< T, Cmp >::Name ( const std::string &  rName)
virtual

Set name of TBaseSet.

Parameters
rNameName to set

Reimplemented from faudes::Type.

Definition at line 1754 of file cfl_baseset.h.

template<class T , class Cmp >
TBaseSet< T, Cmp > faudes::TBaseSet< T, Cmp >::operator* ( const TBaseSet< T, Cmp > &  rOtherSet) const

Set intersection operator.

Returns
Intersection Set

Definition at line 2109 of file cfl_baseset.h.

template<class T , class Cmp >
TBaseSet< T, Cmp > faudes::TBaseSet< T, Cmp >::operator+ ( const TBaseSet< T, Cmp > &  rOtherSet) const

Set union operator.

Returns
Union Set

Definition at line 2094 of file cfl_baseset.h.

template<class T , class Cmp >
TBaseSet< T, Cmp > faudes::TBaseSet< T, Cmp >::operator- ( const TBaseSet< T, Cmp > &  rOtherSet) const

Set difference operator.

Returns
Difference Set

Definition at line 2101 of file cfl_baseset.h.

template<class T , class Cmp >
bool faudes::TBaseSet< T, Cmp >::operator< ( const TBaseSet< T, Cmp > &  rOtherSet) const

Order for sorting containers of TBaseSet.

Definition at line 2138 of file cfl_baseset.h.

template<class T , class Cmp >
bool faudes::TBaseSet< T, Cmp >::operator<= ( const TBaseSet< T, Cmp > &  rOtherSet) const

Test for subset.

Definition at line 2126 of file cfl_baseset.h.

template<class T , class Cmp >
bool faudes::TBaseSet< T, Cmp >::operator>= ( const TBaseSet< T, Cmp > &  rOtherSet) const

Test for superset.

Definition at line 2132 of file cfl_baseset.h.

template<class T , class Cmp >
void faudes::TBaseSet< T, Cmp >::RelinkClients ( void  )
inlineprotected

Ensure that we do not host contents to anyone else.

Definition at line 1487 of file cfl_baseset.h.

template<class T , class Cmp >
void faudes::TBaseSet< T, Cmp >::RestrictSet ( const TBaseSet< T, Cmp > &  rOtherSet)
virtual

Restrict elements given by other set.

Parameters
rOtherSetSet of elements to keep

Definition at line 2058 of file cfl_baseset.h.

template<class T , class Cmp >
Idx faudes::TBaseSet< T, Cmp >::Size ( void  ) const

Get Size of TBaseSet.

Returns
Number of indices in TBaseSet

Definition at line 1813 of file cfl_baseset.h.

template<class T, class Cmp >
std::string faudes::TBaseSet< T, Cmp >::Str ( const T &  rElem) const
virtual
template<class T, class Cmp>
TBaseSet< T, Cmp >::Iterator faudes::TBaseSet< T, Cmp >::ThisIterator ( const typename std::set< T, Cmp >::const_iterator sit) const
protected

Convert STL iterator to API iterator.

Definition at line 1880 of file cfl_baseset.h.

template<class T , class Cmp >
const TypeDefinition * faudes::TBaseSet< T, Cmp >::TypeDefinitionp ( void  ) const
protectedvirtual

Reimplment from type to use chache.

Reimplemented from faudes::Type.

Definition at line 1761 of file cfl_baseset.h.

template<class T , class Cmp >
const std::string & faudes::TBaseSet< T, Cmp >::TypeName ( void  ) const
virtual

Get objects's type name.

Retrieve the faudes-type name from the type registry. Sets allow to overwrite the faudes-type identifier. This is allows for light-weight derived classes that do not need to be registered.

Returns
Faudes-type name or empty string.

Reimplemented from faudes::Type.

Definition at line 1789 of file cfl_baseset.h.

template<class T , class Cmp >
void faudes::TBaseSet< T, Cmp >::TypeName ( const std::string &  rType)
virtual

Overwrite faudes-type name.

This method is used to overwrite the faudes-type identifyer.

Parameters
rTypeFaudes-type name to set

Definition at line 1800 of file cfl_baseset.h.

template<class T, class Cmp >
bool faudes::TBaseSet< T, Cmp >::Valid ( const T &  rElem) const
inlinevirtual

Test validty of candidate element.

Reimplement this function for particular type T of elements, eg for an index set with T=Idx indicate 0 an invalid index.

Parameters
rElemCandidate to test
Returns
True if element is valid

Reimplemented in faudes::IndexSet, and faudes::SymbolSet.

Definition at line 1948 of file cfl_baseset.h.

template<class T , class Cmp >
void faudes::TBaseSet< T, Cmp >::XElementTag ( const std::string &  rTag)
virtual

Configure the element name tag.

This method allows to overwrite the tag used for elements in XML IO. For usual, you will register derived class with the run-time-interface and set the elemen tag for XML IO.

Parameters
rTagName to set

Definition at line 1783 of file cfl_baseset.h.

template<class T , class Cmp >
const std::string & faudes::TBaseSet< T, Cmp >::XElementTag ( void  ) const
protectedvirtual

Get name of elements (used for XML IO)

Definition at line 1771 of file cfl_baseset.h.

Friends And Related Function Documentation

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

allow access to attribute interface class

Definition at line 100 of file cfl_baseset.h.

Member Data Documentation

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 938 of file cfl_baseset.h.

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

Indicate "hosts data to myself only".

Definition at line 944 of file cfl_baseset.h.

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

Current/cached faudes type-name.

Definition at line 993 of file cfl_baseset.h.

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 959 of file cfl_baseset.h.

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 947 of file cfl_baseset.h.

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

Name of this BaseSet.

Definition at line 900 of file cfl_baseset.h.

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 923 of file cfl_baseset.h.

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 941 of file cfl_baseset.h.

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 906 of file cfl_baseset.h.

template<class T, class Cmp = std::less<T>>
std::map< T, AttributeVoid * > faudes::TBaseSet< T, Cmp >::msEmptyAttributes = std::map<T,AttributeVoid*>()
staticprotected

static empty STL map for default constructor

Definition at line 979 of file cfl_baseset.h.

template<class T, class Cmp = std::less<T>>
std::set< T, Cmp > faudes::TBaseSet< T, Cmp >::msEmptySet = std::set<T,Cmp>()
staticprotected

static empty STL set for default constructor

Definition at line 976 of file cfl_baseset.h.

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

Current/cached name of elements (used protected accessor method)

Definition at line 990 of file cfl_baseset.h.

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 920 of file cfl_baseset.h.

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 935 of file cfl_baseset.h.

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 903 of file cfl_baseset.h.

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 987 of file cfl_baseset.h.


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

libFAUDES 2.28a --- 2016.09.13 --- c++ api documentaion by doxygen