13 #ifndef FFA_REFERENCE_H
14 #define FFA_REFERENCE_H
23 using FFaSearcher = FFaDynCB4<FFaFieldContainer*&,int,int,const IntVec&>;
48 void setRef(
int objId,
int typeId);
50 void setRef(
int objId,
int typeId,
const IntVec& assemblyIDs);
95 void write(std::ostream& os)
const;
97 void read(std::istream& is);
262 myData = myDefaultValue = NULL;
274 return myData ? (myData->isNull() ? myData->printMeIfZero() :
true) :
false;
280 if (myData) myData->write(os);
Macros for definition of dynamic callback objects.
Template class for field representation in the FEDEM model database.
std::vector< int > IntVec
Convenience type alias.
Definition: FFaField.H:25
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 copy(const FFaReferenceBase &aReference, bool unresolve=false)
A copy method mostly used by FFaFieldContainer::copy().
Definition: FFaReference.C:486
FFaReferenceBase()
The default constructor initializes the members.
Definition: FFaReference.C:59
void write(std::ostream &os) const
Writes the reference to specified output stream.
Definition: FFaReference.C:339
FFaFieldContainer * getRef() const
Returns the FFaFieldContainer pointer contained.
Definition: FFaReference.C:123
bool isResolved() const
Returns whether this reference has been resolved or not.
Definition: FFaReference.H:62
void unbind()
Tells the referred object that it is not being referred anymore.
Definition: FFaReference.C:466
const char * getRefTypeName() const
Returns the type name of the referred object.
Definition: FFaReference.C:159
bool IAmResolved
false if we have an UnResolvedID object pointed to by myUnresolvedRef
Definition: FFaReference.H:151
void setOwnerReferenceList(FFaReferenceListBase *)
Sets the FFaReferenceListBase that this reference is a member of.
Definition: FFaReference.C:599
bool isNull() const
Returns whether this reference points to an actual object.
Definition: FFaReference.H:64
bool IAmBound
true if myPtr is pointing to a container, and the container knows it
Definition: FFaReference.H:153
void setRefAssemblyID(const IntVec &assemblyID)
Convenience method used when reading from file.
Definition: FFaReference.C:547
bool isEqual(const FFaReferenceBase *p) const
Checks for equality between two references.
Definition: FFaReference.C:615
void setRefID(int id)
Convenience method used when reading from file.
Definition: FFaReference.C:519
const char * myContextName
Typically, this will be the variable name.
Definition: FFaReference.H:169
void zeroOut()
Only used by the FFaReferenceListBase to clean a ToRef.
Definition: FFaReference.C:562
UnResolvedID * myUnresolvedRef
Id of referred object before resolving.
Definition: FFaReference.H:166
void bind()
Tells the object this reference is pointing at that it is referred.
Definition: FFaReference.C:452
FFaReferenceBase & operator=(const FFaReferenceBase &)=delete
Remove implicitly defined assignment operator.
bool setPointerToNull()
Clears the reference.
Definition: FFaReference.H:52
bool printIfZero
If true, print the reference also when NULL.
Definition: FFaReference.H:170
void setPrintIfZero(bool doPrint)
Flags whether this reference should be printed even if NULL.
Definition: FFaReference.H:90
void updateAssemblyRef(int from, int to, size_t ind=0)
Updates the assembly reference when moving to another assembly.
Definition: FFaReference.C:289
bool setRef(FFaFieldContainer *ptr)
Sets the pointer value from a FFaFieldContainer pointer directly.
Definition: FFaReference.C:78
int getRefTypeID() const
Returns the type id of the referred object.
Definition: FFaReference.C:168
FFaFieldContainer * myPtr
Points to the referred object when resolved.
Definition: FFaReference.H:165
void setRefTypeID(int id)
Convenience method used when reading from file.
Definition: FFaReference.C:533
FFaFieldContainer * getOwnerFieldContainer() const
Returns the FFaFieldContainer this reference is a member of.
Definition: FFaReference.C:588
FFaReferenceListBase * getOwnerReferenceList() const
Returns the FFaReferenceListBase this reference is a member of.
Definition: FFaReference.C:606
void clearResolveRef()
Deletes the variable used to hold temporary ID information.
Definition: FFaReference.C:475
bool getRefAssemblyID(IntVec &assID) const
Returns the assembly id array of the referred object.
Definition: FFaReference.C:190
virtual int getRefClassTypeID() const
Returns the type ID that this reference is supposed to refer to.
Definition: FFaReference.H:74
bool printMeIfZero() const
Returns if this reference should be printed even if NULL.
Definition: FFaReference.H:92
void resolve(FFaSearcher &findCB)
Finds the object that has matching Type and ID as read from file.
Definition: FFaReference.C:208
std::vector< int > UnResolvedID
Type of unique identification of the unresolved references.
Definition: FFaReference.H:148
void zeroOutOrRemoveFromList()
Only used by FFaFieldContainer to notify that it is obsolete.
Definition: FFaReference.C:572
void setOwnerFieldContainer(FFaFieldContainer *)
Sets the FFaFieldContainer that this reference is a member of.
Definition: FFaReference.C:581
virtual ~FFaReferenceBase()
The destructor clears the cross references.
Definition: FFaReference.C:67
FFaReferenceBase(const FFaReferenceBase &)=delete
Remove implicitly defined copy constructor.
const char * getContextName() const
Returns the context name used by this reference.
Definition: FFaReference.C:148
void read(std::istream &is)
Reads the reference from specified input stream.
Definition: FFaReference.C:360
void setContextName(const char *name)
Assigns the context name for this reference.
Definition: FFaReference.H:67
void unresolve()
Does the opposite of resolve.
Definition: FFaReference.C:268
bool IAmInAList
true if this reference is maintained by a FFaReferenceList
Definition: FFaReference.H:155
FFaReferenceListBase * myOwnerList
Points to the owner reference list.
Definition: FFaReference.H:160
FFaFieldContainer * myOwnerObj
Points to the owner object.
Definition: FFaReference.H:159
int getRefID() const
Returns the id number of the referred object.
Definition: FFaReference.C:179
The base class for FFaReferenceList.
Definition: FFaReferenceList.H:34
A "guarded pointer" like class.
Definition: FFaReference.H:221
FFaReference< Type > & operator=(Type *ptr)
Overloaded assignment operator.
Definition: FFaReference.H:229
int getRefClassTypeID() const final
Returns the class type ID this reference is instantiated over.
Definition: FFaReference.H:248
bool operator==(const FFaReference< Type > &p) const
Equality operator.
Definition: FFaReference.H:243
bool operator!=(const FFaReference< Type > &p) const
Inequality operator.
Definition: FFaReference.H:245
Type * getPointer() const
Returns the type-casted pointer this reference points to.
Definition: FFaReference.H:234
bool setPointer(Type *ptr)
Assigns ptr to this reference.
Definition: FFaReference.H:227
Type & operator*() const
Dereference operator.
Definition: FFaReference.H:240
Type * operator->() const
Pointer operator.
Definition: FFaReference.H:238