13 #ifndef FFA_REFERENCE_LIST_H
14 #define FFA_REFERENCE_LIST_H
58 bool erase(
int index);
74 void getBasePtrs(std::vector<FFaFieldContainer*>& toFill)
const;
84 void write(std::ostream& os)
const;
86 void read(std::istream& is);
198 { this->
setPtrs(ptrs);
return *
this; }
213 std::list<FFaReferenceBase*>::iterator it =
myRefs.end();
229 std::list<FFaReferenceBase*>::iterator it;
230 for (it =
myRefs.begin(); it !=
myRefs.end(); i++, it++)
241 void getPtrs(std::vector<Type*>& toFill,
bool includeNullToo =
false)
const
245 if (includeNullToo || !ref->isNull())
253 for (Type* ptr : ptrs)
280 std::cerr <<
"FFaReference::operator[]: Index "<< idx
281 <<
" out of range [0,"<< this->
size() <<
"]"<< std::endl;
292 std::cerr <<
"FFaReference::operator[]: Index "<< idx
293 <<
" out of range [0,"<< this->
size() <<
"]"<< std::endl;
304 std::list<FFaReferenceBase*>::iterator it;
305 for (it =
myRefs.begin(); it !=
myRefs.end(); i++, it++)
351 if (ID) sr->
setRef(ID,Type::getClassTypeID());
368 myData = myDefaultValue = NULL;
371 template<>
inline bool
377 template<>
inline bool
380 return myData ? !myData->empty() :
false;
383 template<>
inline void
386 if (myData) myData->write(os);
389 template<>
inline void
std::vector< int > IntVec
Convenience type alias.
Definition: FFaField.H:25
Classes representing guarded pointers.
FFaDynCB4< FFaFieldContainer *&, int, int, const IntVec & > FFaSearcher
Callback searching for FFaFieldContainer objects when resolving references.
Definition: FFaReference.H:23
Base class for the FEDEM model database structure.
Definition: FFaFieldContainer.H:39
FFaField()
Empty default constructor.
Definition: FFaField.H:42
bool isPrintable() const override
Returns true, if this field should be printed.
Definition: FFaField.H:94
void read(std::istream &is) override
Reads the field value from an input stream.
Definition: FFaField.H:117
bool isDataField() const override
Returns true, if this is a numerical data field.
Definition: FFaField.H:93
void write(std::ostream &os) const override
Writes the field name and value to an output stream.
Definition: FFaField.H:116
Base class for the template class FFaReference for guarded pointers.
Definition: FFaReference.H:31
void setOwnerReferenceList(FFaReferenceListBase *)
Sets the FFaReferenceListBase that this reference is a member of.
Definition: FFaReference.C:599
bool setRef(FFaFieldContainer *ptr)
Sets the pointer value from a FFaFieldContainer pointer directly.
Definition: FFaReference.C:78
The base class for FFaReferenceList.
Definition: FFaReferenceList.H:34
void resolve(FFaSearcher &findCB)
Used after reading to translate IDs to actual pointers.
Definition: FFaReferenceList.C:207
const char * myContext
Typically, this will be the variable name.
Definition: FFaReferenceList.H:143
FFaReferenceList::const_iterator findPtr(const FFaFieldContainer *ptr) const
Returns a const_iterator matching a FFaFieldContainer pointer.
Definition: FFaReferenceList.C:84
FFaReferenceListBase & operator=(const FFaReferenceListBase &)=delete
Remove implicitly defined assignment operator,.
void setOwnerOnRef(FFaReferenceBase *pt)
Sets this list as the owner of the reference pt.
Definition: FFaReferenceList.H:109
FFaReferenceBase * getRefBase(int idx) const
Returns the pointer at index idx.
Definition: FFaReferenceList.C:128
void setOwnerFieldContainer(FFaFieldContainer *owner)
Sets the FFaFieldContainer that this reference list is a member of.
Definition: FFaReferenceList.H:121
FFaFieldContainer * getOwnerFieldContainer() const
Returns the FFaFieldContainer this reference list is a member of.
Definition: FFaReferenceList.H:123
void insertRefLast(FFaReferenceBase *ref)
Appends a reference to the end of myRefs.
Definition: FFaReferenceList.C:163
void updateAssemblyRef(int from, int to, size_t ind=0)
Updates the assembly reference when moving to another assembly.
Definition: FFaReferenceList.C:226
bool isAutoSizing() const
Returns the value of the autoSizing flag.
Definition: FFaReferenceList.H:50
void setContextName(const char *name)
Assigns the context name myContext for this reference.
Definition: FFaReferenceList.H:53
void setAutoSizing(bool onOrOff)
Sets the autoSizing flag.
Definition: FFaReferenceList.H:48
void write(std::ostream &os) const
Writes the reference list to specified output stream.
Definition: FFaReferenceList.C:240
bool shuffle(size_t newFirst)
Reorders the elements in the list.
Definition: FFaReferenceList.C:23
FFaReferenceListBase()
The default constructor initializes the members.
Definition: FFaReferenceList.H:42
void eraseReferenceIfNeeded(FFaReferenceBase *ref)
Removes a reference from the list.
Definition: FFaReferenceList.C:295
void clear()
Clears the reference list.
Definition: FFaReferenceList.C:187
void unresolve()
Does the opposite of resolve.
Definition: FFaReferenceList.C:219
FFaFieldContainer * getBasePtr(int idx) const
Returns the pointer to the idx'th member in the list.
Definition: FFaReferenceList.C:138
void getBasePtrs(std::vector< FFaFieldContainer * > &toFill) const
Fills provided vector with the non-NULL pointers in the list.
Definition: FFaReferenceList.C:198
void zeroOutPtr(const FFaFieldContainer *ptr)
Sets all instances of ptr in this list to zero.
Definition: FFaReferenceList.H:69
virtual ~FFaReferenceListBase()
The destructor clears the list.
Definition: FFaReferenceList.H:44
void read(std::istream &is)
Reads the reference list from specified input stream.
Definition: FFaReferenceList.C:255
bool erase(int index)
Erases entry index from the list, decrementing its size by one.
Definition: FFaReferenceList.C:172
virtual FFaReferenceBase * createNewReference() const =0
Virtual method for creating a FFaReference of correct type.
bool empty() const
Returns true if myRefs is empty (zero length).
Definition: FFaReferenceList.H:81
void copy(const FFaReferenceListBase *other, bool unresolve=false)
Copy method used by copy constructors, etc.
Definition: FFaReferenceList.C:145
void removePtr(const FFaFieldContainer *ptr)
Removes all instances of ptr from this list.
Definition: FFaReferenceList.H:67
FFaReferenceList myRefs
The actual list of references.
Definition: FFaReferenceList.H:92
FFaReferenceListBase(const FFaReferenceListBase &)=delete
Remove implicitly defined copy constructor.
size_t size() const
Returns the length of myRefs,.
Definition: FFaReferenceList.H:79
bool autoSizing
Definition: FFaReferenceList.H:147
bool hasPtr(const FFaFieldContainer *ptr, int *index=NULL) const
Returns true if ptr is present in the list.
Definition: FFaReferenceList.C:113
void reverse()
Inverts the element order in the list.
Definition: FFaReferenceList.H:65
const char * getContextName() const
Returns the context name myContext used by this reference.
Definition: FFaReferenceList.H:55
FFaFieldContainer * myOwner
Points to the owner object.
Definition: FFaReferenceList.H:142
A container of FFaReference objects (guarded pointers).
Definition: FFaReferenceList.H:194
void insertPtrAfter(Type *ptr, Type *objInList=NULL)
Insert ptr after objInList in the list.
Definition: FFaReferenceList.H:211
void push_back(Type *ptr, bool insertNullToo=false)
Inserts ptr at the end of the list.
Definition: FFaReferenceList.H:205
FFaReference< Type > & operator[](int idx)
Indexing operator (for update).
Definition: FFaReferenceList.H:275
const FFaReference< Type > & operator[](int idx) const
Indexing operator (for read only).
Definition: FFaReferenceList.H:287
void push_front(Type *ptr, bool insertNullToo=false)
Inserts ptr in the front of the list.
Definition: FFaReferenceList.H:201
void setPtrs(const std::vector< Type * > &ptrs)
Replaces the current contents with the provided vector of pointers.
Definition: FFaReferenceList.H:250
void setPtr(Type *ptr, int idx)
Assigns ptr at position idx.
Definition: FFaReferenceList.H:301
Type * getFirstPtr() const
Returns the first pointer, or NULL if myRefs is empty.
Definition: FFaReferenceList.H:329
FFaReferenceBase * createNewReference() const final
Virtual method for creating a FFaReference of correct type.
Definition: FFaReferenceList.H:355
Type * getLastPtr() const
Returns the last pointer, or NULL if myRefs is empty.
Definition: FFaReferenceList.H:337
void setRefs(const IntVec &IDs)
Replaces the current contents with the provided new references.
Definition: FFaReferenceList.H:258
FFaReferenceList< Type > & operator=(const std::vector< Type * > &ptrs)
Overloaded assignment operator.
Definition: FFaReferenceList.H:197
FFaReference< Type > * makeNewRef(Type *ptr, int ID=0)
Convenience method to create and set up a new reference properly.
Definition: FFaReferenceList.H:346
Type * getPtr(int idx) const
Returns the pointer at position idx.
Definition: FFaReferenceList.H:320
void getPtrs(std::vector< Type * > &toFill, bool includeNullToo=false) const
Fills the provided vector with the pointers contained in the list.
Definition: FFaReferenceList.H:241
void insert(Type *ptr, size_t idx=0)
Inserts ptr at position idx in the list.
Definition: FFaReferenceList.H:226
A "guarded pointer" like class.
Definition: FFaReference.H:221
bool setPointer(Type *ptr)
Assigns ptr to this reference.
Definition: FFaReference.H:227