#include <cfl_indexset.h>

Public Member Functions

 IndexSet (void)
 
 IndexSet (const IndexSet &rOtherSet)
 
 IndexSet (const TBaseSet< Idx > &rOtherSet)
 
 IndexSet (const std::string &rFilename, const std::string &rLabel="")
 
virtual ~IndexSet (void)
 
Idx MaxIndex (void) const
 
bool Valid (const Idx &rIndex) const
 
Idx Insert (void)
 
bool Insert (const Idx &rIndex)
 
Idx Signature (void) const
 
std::string Str (const Idx &rIndex) const
 
- Public Member Functions inherited from faudes::TBaseSet< Idx >
 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 Idx &rElem) const
 
Iterator Begin (void) const
 
Iterator End (void) const
 
virtual bool Valid (const Idx &rElem) const
 
virtual bool Erase (const Idx &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 Idx &rElem)
 
virtual Iterator Inject (const Iterator &pos, const Idx &rElem)
 
virtual void Inject (const Idx &rElem)
 
virtual void InsertSet (const TBaseSet &rOtherSet)
 
bool Exists (const Idx &rElem) const
 
Iterator Find (const Idx &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 Idx &rElem)
 
virtual const AttributeVoidAttribute (const Idx &rElem) const
 
virtual void Attribute (const Idx &rElem, const Type &rAttr)
 
virtual void AttributeTry (const Idx &rElem, const Type &rAttr)
 
virtual void ClrAttribute (const Idx &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 Member Functions

void DoAssign (const IndexSet &rSource)
 
virtual void DoWrite (TokenWriter &tw, const std::string &rLabel="", const Type *pContext=0) const
 
virtual void DoXWrite (TokenWriter &tw, const std::string &rLabel="", const Type *pContext=0) const
 
virtual void DoRead (TokenReader &rTr, const std::string &rLabel="", const Type *pContext=0)
 
- Protected Member Functions inherited from faudes::TBaseSet< Idx >
virtual const std::string & XElementTag (void) const
 
virtual void DoDWrite (TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const
 
virtual void DoSWrite (TokenWriter &rTw) const
 
void DoAssign (const TBaseSet &rSourceSet)
 
bool DoEqual (const TBaseSet &rOtherSet) const
 
void DoAttribute (const Idx &rElem, const Type *pAttr)
 
const AttributeVoidDoAttribute (const Idx &rElem) const
 
AttributeVoidDoAttributeExplicit (const Idx &rElem)
 
TBaseSet< Idx, std::less< Idx > >::Iterator ThisIterator (const typename std::set< Idx, std::less< Idx > >::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
 
- Protected Member Functions inherited from faudes::Type
void DoAssign (const Type &rSrc)
 
bool DoEqual (const Type &rOther) const
 
virtual Token XBeginTag (const std::string &rLabel="", const std::string &rFallbackLabel="") const
 

Friends

template<class Attr >
class TaIndexSet
 

Additional Inherited Members

- Public Types inherited from faudes::TBaseSet< Idx >
enum  DetachMode
 
- Protected Types inherited from faudes::TBaseSet< Idx >
typedef std::set< Idx, std::less< Idx > >::iterator iterator
 
typedef std::set< Idx, std::less< Idx > >::const_iterator const_iterator
 
typedef std::map< Idx, AttributeVoid * >::iterator aiterator
 
typedef std::map< Idx, AttributeVoid * >::const_iterator const_aiterator
 
- Protected Attributes inherited from faudes::TBaseSet< Idx >
std::string mMyName
 
std::set< Idx, std::less< Idx > > * pSet
 
std::set< Idx, std::less< Idx > > * mpSet
 
std::map< Idx, AttributeVoid * > * pAttributes
 
std::map< Idx, AttributeVoid * > * mpAttributes
 
TBaseSet< Idx, std::less< Idx > > * pHostSet
 
std::list< TBaseSet< Idx, std::less< Idx > > * >::iterator mClientRecord
 
std::list< TBaseSet< Idx, std::less< Idx > > * > * mpClients
 
bool mDetached
 
bool mLocked
 
std::set< Iterator * > mIterators
 
std::string mXElementTagDef
 
- Static Protected Attributes inherited from faudes::TBaseSet< Idx >
static std::set< Idx, std::less< Idx > > msEmptySet
 
static std::map< Idx, AttributeVoid * > msEmptyAttributes
 

Detailed Description

Set of indices. This class is built on top of the faudes version TBaseSet of STL sets. It provides the essentials of the STL interface and inherits the standard token IO interface from Type, so you may use Read and Write for file/string/console IO.

IndexSet is used as common base for TaIndexSet (indices with attributes), NameSet (indices with symbolic names) and TaNameSet (indices with attributes and symbolic names).

The index of value 0 is reserved to indicate the invalid index. If the macro FAUDES_CHECKED is defined, the attempt to insert an index 0 triggers an exception (id 61). Invalid iterators throw an exception (id 62) when used as an argument to a IndexSet function.

Technically, file IO is done by TaIndexSet functions. This requires a copy and for that reason may be reimplemented in a future versions. The format is demonstrated by the following example of a set with name "MySet" consisting of indices 17, 25, 26, 27, 28, 40:

<Myset>
17
<Consecutive> 25 4 </Consecutive>
40
</MySet>

Theere is a minimum number of consecutive indices for the use of the consecutive section defined in definitions.h.

Definition at line 78 of file cfl_indexset.h.

Constructor & Destructor Documentation

◆ IndexSet() [1/4]

faudes::IndexSet::IndexSet ( void  )

Constructor.

Definition at line 55 of file cfl_indexset.cpp.

◆ IndexSet() [2/4]

faudes::IndexSet::IndexSet ( const IndexSet rOtherSet)

Copy-constructor.

Definition at line 61 of file cfl_indexset.cpp.

◆ IndexSet() [3/4]

faudes::IndexSet::IndexSet ( const TBaseSet< Idx > &  rOtherSet)

Copy-constructor.

Definition at line 69 of file cfl_indexset.cpp.

◆ IndexSet() [4/4]

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

Construct from file. Uses the Read(TokenReader&, const std::string&) function to read. a IndexSet from section rLabel in file rFilename.

Parameters
rFilenameName of file to read
rLabelSection to read
Exceptions
Exception
  • IO Errors (id 1)
  • Token mismatch (id 50, 51, 52)

Definition at line 77 of file cfl_indexset.cpp.

◆ ~IndexSet()

virtual faudes::IndexSet::~IndexSet ( void  )
inlinevirtual

Virtual destructor

Definition at line 128 of file cfl_indexset.h.

Member Function Documentation

◆ DoAssign()

void faudes::IndexSet::DoAssign ( const IndexSet rSource)
protected

Assign my members. This method maintains attributes provided that the type can be appropriately casted.

Parameters
rSourceSource to copy from

Definition at line 85 of file cfl_indexset.cpp.

◆ DoRead()

void faudes::IndexSet::DoRead ( TokenReader rTr,
const std::string &  rLabel = "",
const Type pContext = 0 
)
protectedvirtual

Read from TokenReader, see Type::Read for public wrappers. This method invokes TokenReader::ReadBegin() to seek the specified section, reads subsequent integer tokens as indexes, and calls matching TokenReader::ReadEnd(). If no section is specified, the section is assumed to start at the current position of the token stream. If the current position is no begin token, the section "IndexSet" is read. When used by a derived class with attributes, attributes are read, too.

Parameters
rTrReference to tokenreader
rLabelSection to read, defaults to current begin label or else "IndexSet"
pContextRead context to provide contextual information
Exceptions
Exception
  • IO errors (id 1)
  • token mismatch (id 50, 51, 52)

Reimplemented from faudes::TBaseSet< Idx >.

Definition at line 198 of file cfl_indexset.cpp.

◆ DoWrite()

void faudes::IndexSet::DoWrite ( TokenWriter tw,
const std::string &  rLabel = "",
const Type pContext = 0 
) const
protectedvirtual

Write to TokenWriter, see Type::Write for public wrappers. Appends the IndexSet to TokenWriter. This will write a section with label as specified that holds integer tokens to represent the IndexSet. For non-default attribute values, the respective index is followed by the attribute value. The latter may consist of sections (or tokens different from integer or string) to allow for transparent reading; see AttributeVoid and AttributeFlags. Example for a set with name "MySet" consisting of indices 17, 25, 40, where index 25 has a nontrivial attribute attached:

<Myset>
17
25 <AValue> "Some Value" </AValue>
40
</MySet>
Parameters
twReference to TokenWriter
rLabelLabel of section to write, defaults to name of set or "IndexSet"
pContextWrite context to provide contextual information
Exceptions
Exception
  • IO errors (id 2)

Reimplemented from faudes::TBaseSet< Idx >.

Definition at line 92 of file cfl_indexset.cpp.

◆ DoXWrite()

void faudes::IndexSet::DoXWrite ( TokenWriter tw,
const std::string &  rLabel = "",
const Type pContext = 0 
) const
protectedvirtual

Write to TokenWriter, see Type::Write for public wrappers. Appends the IndexSet to TokenWriter using XML format.

Parameters
twReference to TokenWriter
rLabelLabel of section to write, defaults to name of set or "IndexSet"
pContextWrite context to provide contextual information
Exceptions
Exception
  • IO errors (id 2)

Reimplemented from faudes::Type.

Definition at line 142 of file cfl_indexset.cpp.

◆ Insert() [1/2]

bool faudes::IndexSet::Insert ( const Idx rIndex)

Insert specified index

Parameters
rIndexIndex to insert
Returns
True if index was new to set

Definition at line 322 of file cfl_indexset.cpp.

◆ Insert() [2/2]

Idx faudes::IndexSet::Insert ( void  )

Insert new index to set

Returns
New index

Definition at line 313 of file cfl_indexset.cpp.

◆ MaxIndex()

Idx faudes::IndexSet::MaxIndex ( void  ) const

Get maximum index used in this set (0 for emptyset)

Returns
max indices

Definition at line 298 of file cfl_indexset.cpp.

◆ Signature()

Idx faudes::IndexSet::Signature ( void  ) const

Compute an Idx type signature for a Set. The value is computed by summing up the product of every index with an integer starting at 1 (for the first index) and ending at Size() (for the last index).

Returns
Idx type set signature

Definition at line 335 of file cfl_indexset.cpp.

◆ Str()

std::string faudes::IndexSet::Str ( const Idx rIndex) const
inline

Return pretty printable index.

Parameters
rIndexIndex to print
Returns
String

Definition at line 189 of file cfl_indexset.h.

◆ Valid()

bool faudes::IndexSet::Valid ( const Idx rIndex) const

Test whether index is not 0

Parameters
rIndexIndex to test
Returns
True if idx!=0

Definition at line 329 of file cfl_indexset.cpp.

Friends And Related Function Documentation

◆ TaIndexSet

template<class Attr >
friend class TaIndexSet ( void  )
friend

We implement "protected privacy for template classes" by friendship. This is used for the pragmatic implemention conversion constructors.

Definition at line 92 of file cfl_indexset.h.


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

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