FEDEM Model Database  R8.0
Source code of the FEDEM model database
Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | Private Types | Private Member Functions | Private Attributes | Friends | List of all members
FFaFieldContainer Class Reference

Base class for the FEDEM model database structure. More...

#include <FFaFieldContainer.H>

Inheritance diagram for FFaFieldContainer:
Inheritance graph
[legend]

Classes

struct  FDictLess
 Functor for comparison of dictionary entries. More...
 

Public Types

using FindCB = FFaDynCB4< FFaFieldContainer *&, int, int, const IntVec & >
 Convenience alias for resolve call-backs. More...
 

Public Member Functions

 FFaFieldContainer ()
 The default constructor does nothing. More...
 
virtual ~FFaFieldContainer ()
 The destructor clears the references to *this in myRefBy. More...
 
bool erase ()
 Deletes *this assuming it is heap-allocated. More...
 
void getFields (FieldMap &mapToFill) const
 Builds a map of all fields in this FFaFieldContainer. More...
 
FFaFieldBase * getField (const std::string &fieldName) const
 Returns the named field in this FFaFieldContainer. More...
 
void getReferredObjs (ObjectMap &mapToFill) const
 Builds a map of all other objects referred to by *this. More...
 
void getReferringObjs (ObjectMap &mapToFill) const
 Builds a map of all other objects referring to *this. More...
 
void getReferringObjs (ObjectVec &vecToFill, const std::string &contextName, bool sortOnId=false) const
 Builds a list of FFaFieldContainer objects referring to *this. More...
 
template<class T >
void getReferringObjs (std::vector< T * > &vecToFill, const std::string &context="", bool sortOnId=false) const
 Builds a list of class T objects referring to *this. More...
 
template<class T >
bool hasReferringObjs (T *&ptr, const std::string &context="") const
 Checks if there are any references of type T to this object. More...
 
void releaseReferencesToMe (const std::string &contextName="", FFaFieldContainer *replacement=NULL)
 Directly removes all references to this object. More...
 
void resolve (FindCB &findCB)
 Resolves all FFaReferences and FFaReferenceLists in this object. More...
 
void unresolve ()
 Unresolves all FFaReferences and FFaReferenceLists in this object. More...
 
virtual void initAfterResolve ()
 Initializes the fields after resolve. More...
 
virtual int getResolvedID () const
 Returns the user Id of *this, for use in I/O and resolving. More...
 
virtual void getResolvedAssemblyID (IntVec &) const
 Gets the assembly path of *this, for use in I/O and resolving. More...
 
void updateReferences (int oldAssId, int newAssId)
 Updates the assembly ID in the references in this object. More...
 
void updateReferences (const IntVec &oldAssId, const IntVec &newAssID)
 Updates the assembly ID in the references in this object. More...
 
bool readField (const std::string &key, std::istream &is, bool datafieldsOnly=false)
 Reads the value of a field named key from an input stream. More...
 
bool copy (const FFaFieldContainer *other, bool fieldsOnly=false, bool unresolve=false)
 Copies all fields and references from another object into *this. More...
 
bool copyFields (const FFaFieldContainer *obj)
 Copies all field values from another object into *this. More...
 
bool resetFields (const FFaFieldContainer *obj)
 Resets fields to their default value. More...
 

Static Public Member Functions

static void removeDictInstance ()
 Removes the heap-allocated field name dictionary. More...
 

Protected Types

using FDict = std::set< std::string >
 Convenience type alias, a set of text strings used as a dictionary. More...
 
using FDictIt = FDict::const_iterator
 Convenience type alias, a const_iterator pointing into a dictionary. More...
 
using FieldContainerMap = std::map< FDictIt, FFaFieldBase *, FDictLess >
 Convenience type alias, a field container map. More...
 
using FieldContainerDict = FFaSingelton< FDict, FFaFieldContainer >
 Convenience type alias, a heap-allocated dictionary singelton. More...
 

Protected Member Functions

virtual bool eraseOptions ()
 Hook for class-specific tasks before deleting *this in erase(). More...
 
void addRef (FFaReferenceBase *ref)
 Adds a reference to the internal book keeping of this object. More...
 
void addRefList (FFaReferenceListBase *list)
 Adds a reference list to the internal book keeping of this object. More...
 
void addField (const std::string &identifier, FFaFieldBase *field)
 Adds a field to the internal book keeping of this object. More...
 
void removeField (const std::string &identifier)
 Removes the field from the internal book keeping of this object. More...
 

Protected Attributes

FieldContainerMap myFields
 All data fields of this object. More...
 

Private Types

using IntVec = std::vector< int >
 Convenience type alias. More...
 
using FieldMap = std::map< std::string, FFaFieldBase * >
 Convenience type alias. More...
 
using ObjectMap = std::multimap< std::string, FFaFieldContainer * >
 Convenience type alias. More...
 
using ObjectVec = std::vector< FFaFieldContainer * >
 Convenience type alias. More...
 
using ReferenceSet = std::vector< FFaReferenceBase * >
 Convenience type alias. More...
 

Private Member Functions

void insertInRefBy (FFaReferenceBase *ref)
 Marks this object as referred to by another object. More...
 
void deleteFromRefBy (FFaReferenceBase *ref)
 Unmarks this object as no longer referred to by another object. More...
 
FFaFieldContainer * getNext (const std::string &context, bool getFirst=false) const
 Helper for template functions to loop over all objects in myRefBy. More...
 

Private Attributes

ReferenceSet myRefBy
 List of all objects referring to *this. More...
 
std::list< FFaReferenceBase * > myRefTo
 List of all objects *this is referring to. More...
 
std::list< FFaReferenceListBase * > myRefLists
 List of all listed objects *this is referring to. More...
 

Friends

class FFaReferenceBase
 Grants access to some private methods for resolving references. More...
 

Detailed Description

Base class for the FEDEM model database structure.

This class contains the core of the model database structure. It manages FFaField, FFaReference and FFaReferenceList members in derived subclasses, and provides automated I/O, single and multiple guarded pointers.

Member Typedef Documentation

◆ FDict

using FFaFieldContainer::FDict = std::set<std::string>
protected

Convenience type alias, a set of text strings used as a dictionary.

◆ FDictIt

using FFaFieldContainer::FDictIt = FDict::const_iterator
protected

Convenience type alias, a const_iterator pointing into a dictionary.

◆ FieldContainerDict

Convenience type alias, a heap-allocated dictionary singelton.

◆ FieldContainerMap

Convenience type alias, a field container map.

◆ FieldMap

using FFaFieldContainer::FieldMap = std::map<std::string,FFaFieldBase*>
private

Convenience type alias.

◆ FindCB

using FFaFieldContainer::FindCB = FFaDynCB4<FFaFieldContainer*&,int,int,const IntVec&>

Convenience alias for resolve call-backs.

◆ IntVec

using FFaFieldContainer::IntVec = std::vector<int>
private

Convenience type alias.

◆ ObjectMap

using FFaFieldContainer::ObjectMap = std::multimap<std::string,FFaFieldContainer*>
private

Convenience type alias.

◆ ObjectVec

using FFaFieldContainer::ObjectVec = std::vector<FFaFieldContainer*>
private

Convenience type alias.

◆ ReferenceSet

using FFaFieldContainer::ReferenceSet = std::vector<FFaReferenceBase*>
private

Convenience type alias.

Constructor & Destructor Documentation

◆ FFaFieldContainer()

FFaFieldContainer::FFaFieldContainer ( )

The default constructor does nothing.

◆ ~FFaFieldContainer()

FFaFieldContainer::~FFaFieldContainer ( )
virtual

The destructor clears the references to *this in myRefBy.

Member Function Documentation

◆ addField()

void FFaFieldContainer::addField ( const std::string &  identifier,
FFaFieldBase *  field 
)
protected

Adds a field to the internal book keeping of this object.

◆ addRef()

void FFaFieldContainer::addRef ( FFaReferenceBase *  ref)
protected

Adds a reference to the internal book keeping of this object.

◆ addRefList()

void FFaFieldContainer::addRefList ( FFaReferenceListBase *  list)
protected

Adds a reference list to the internal book keeping of this object.

◆ copy()

bool FFaFieldContainer::copy ( const FFaFieldContainer *  other,
bool  fieldsOnly = false,
bool  unresolve = false 
)

Copies all fields and references from another object into *this.

This method copies all fields, references and reference lists from the supplied FFaFieldContainer object *other into *this.

The big assumption is that the field containers are of the same type, and thus has the same number of references and in the same order.

If fieldsOnly is true only the current field values are copied, whereas the default values, references and reference list are not copied.

If unresolve is true, the references are copied but left unresolved, unless the ID is -1.

◆ copyFields()

bool FFaFieldContainer::copyFields ( const FFaFieldContainer *  obj)
inline

Copies all field values from another object into *this.

◆ deleteFromRefBy()

void FFaFieldContainer::deleteFromRefBy ( FFaReferenceBase *  ref)
private

Unmarks this object as no longer referred to by another object.

Used by FFaReferenceBase only.

This method removes the supplied reference from book keeping to notify this object that it is no longer pointed to by the reference. A part of the core of the FFaReference system.

◆ erase()

bool FFaFieldContainer::erase ( )

Deletes *this assuming it is heap-allocated.

◆ eraseOptions()

virtual bool FFaFieldContainer::eraseOptions ( )
inlineprotectedvirtual

Hook for class-specific tasks before deleting *this in erase().

Reimplemented in FmTriad, FmSubAssembly, FmModelMemberBase, FmTurbine, FmSMJointBase, FmSimpleSensor, FmMMJointBase, FmIsPlottedBase, and Fm1DMaster.

◆ getField()

FFaFieldBase * FFaFieldContainer::getField ( const std::string &  fieldName) const

Returns the named field in this FFaFieldContainer.

◆ getFields()

void FFaFieldContainer::getFields ( FieldMap &  mapToFill) const

Builds a map of all fields in this FFaFieldContainer.

The field identifier, which also is the keyword used in the model file, is used as key in the mapToFill.

◆ getNext()

FFaFieldContainer * FFaFieldContainer::getNext ( const std::string &  context,
bool  getFirst = false 
) const
private

Helper for template functions to loop over all objects in myRefBy.

◆ getReferredObjs()

void FFaFieldContainer::getReferredObjs ( ObjectMap &  mapToFill) const

Builds a map of all other objects referred to by *this.

The object pointers are accompanied by the context name the references have for the referred objects. The context names are used as key in mapToFill.

◆ getReferringObjs() [1/3]

void FFaFieldContainer::getReferringObjs ( ObjectMap &  mapToFill) const

Builds a map of all other objects referring to *this.

The object pointers are accompanied by the context name the references have for the referring objects. The context names are used as key in mapToFill.

◆ getReferringObjs() [2/3]

void FFaFieldContainer::getReferringObjs ( ObjectVec &  vecToFill,
const std::string &  contextName,
bool  sortOnId = false 
) const

Builds a list of FFaFieldContainer objects referring to *this.

This method gets the list of objects referring to this object with the context contextName. The list is sorted w.r.t. the ID if sortOnId is true. This is needed when the execution order is of importance. If the list is not sorted, the order might be different in two consecutive runs of the same model.

Note
The output array vecToFill is not cleared on entry.

◆ getReferringObjs() [3/3]

template<class T >
void FFaFieldContainer::getReferringObjs ( std::vector< T * > &  vecToFill,
const std::string &  context = "",
bool  sortOnId = false 
) const
inline

Builds a list of class T objects referring to *this.

◆ getResolvedAssemblyID()

virtual void FFaFieldContainer::getResolvedAssemblyID ( IntVec &  ) const
inlinevirtual

Gets the assembly path of *this, for use in I/O and resolving.

Reimplemented in FmBase.

◆ getResolvedID()

virtual int FFaFieldContainer::getResolvedID ( ) const
inlinevirtual

Returns the user Id of *this, for use in I/O and resolving.

Reimplemented in FmBase.

◆ hasReferringObjs()

template<class T >
bool FFaFieldContainer::hasReferringObjs ( T *&  ptr,
const std::string &  context = "" 
) const
inline

Checks if there are any references of type T to this object.

The pointer to the first object, if any, is returned in ptr.

◆ initAfterResolve()

virtual void FFaFieldContainer::initAfterResolve ( )
inlinevirtual

◆ insertInRefBy()

void FFaFieldContainer::insertInRefBy ( FFaReferenceBase *  ref)
private

Marks this object as referred to by another object.

Used by FFaReferenceBase only.

This method inserts the supplied reference into the book keeping to notify this object that it is pointed to by the reference. A part of the core of the FFaReference system.

◆ readField()

bool FFaFieldContainer::readField ( const std::string &  key,
std::istream &  is,
bool  datafieldsOnly = false 
)

Reads the value of a field named key from an input stream.

◆ releaseReferencesToMe()

void FFaFieldContainer::releaseReferencesToMe ( const std::string &  contextName = "",
FFaFieldContainer *  replacement = NULL 
)

Directly removes all references to this object.

This method is used to make some (or all) of the references pointing to this object, point to the object replacement instead, if specified.

Only the references with the supplied contextName are changed, unless contextName is empty (then all references to the object will be changed).

◆ removeDictInstance()

static void FFaFieldContainer::removeDictInstance ( )
inlinestatic

Removes the heap-allocated field name dictionary.

◆ removeField()

void FFaFieldContainer::removeField ( const std::string &  identifier)
protected

Removes the field from the internal book keeping of this object.

◆ resetFields()

bool FFaFieldContainer::resetFields ( const FFaFieldContainer *  other)

Resets fields to their default value.

Only the fields that are present in the supplied container *other are reset. This method therefore inverts the effect of the copy() method (with fieldsOnly = true).

◆ resolve()

void FFaFieldContainer::resolve ( FindCB &  findCB)

Resolves all FFaReferences and FFaReferenceLists in this object.

See also
FFaReferenceBase::resolve
FFaReferenceListBase::resolve

◆ unresolve()

void FFaFieldContainer::unresolve ( )

Unresolves all FFaReferences and FFaReferenceLists in this object.

See also
FFaReferenceBase::unresolve
FFaReferenceListBase::unresolve

◆ updateReferences() [1/2]

void FFaFieldContainer::updateReferences ( const IntVec &  oldAssId,
const IntVec &  newAssID 
)

Updates the assembly ID in the references in this object.

◆ updateReferences() [2/2]

void FFaFieldContainer::updateReferences ( int  oldAssId,
int  newAssId 
)

Updates the assembly ID in the references in this object.

Friends And Related Function Documentation

◆ FFaReferenceBase

friend class FFaReferenceBase
friend

Grants access to some private methods for resolving references.

Member Data Documentation

◆ myFields

FieldContainerMap FFaFieldContainer::myFields
protected

All data fields of this object.

◆ myRefBy

ReferenceSet FFaFieldContainer::myRefBy
private

List of all objects referring to *this.

◆ myRefLists

std::list<FFaReferenceListBase*> FFaFieldContainer::myRefLists
private

List of all listed objects *this is referring to.

◆ myRefTo

std::list<FFaReferenceBase*> FFaFieldContainer::myRefTo
private

List of all objects *this is referring to.


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