FEDEM Model Database  R8.0
Source code of the FEDEM model database
Public Member Functions | List of all members
FFaReference< Type > Class Template Reference

A "guarded pointer" like class. More...

#include <FFaReference.H>

Inheritance diagram for FFaReference< Type >:
Inheritance graph
[legend]
Collaboration diagram for FFaReference< Type >:
Collaboration graph
[legend]

Public Member Functions

bool setPointer (Type *ptr)
 Assigns ptr to this reference. More...
 
FFaReference< Type > & operator= (Type *ptr)
 Overloaded assignment operator. More...
 
Type * getPointer () const
 Returns the type-casted pointer this reference points to. More...
 
 operator Type * () const
 Pointer operator. More...
 
Type * operator-> () const
 Pointer operator. More...
 
Type & operator* () const
 Dereference operator. More...
 
bool operator== (const FFaReference< Type > &p) const
 Equality operator. More...
 
bool operator!= (const FFaReference< Type > &p) const
 Inequality operator. More...
 
int getRefClassTypeID () const final
 Returns the class type ID this reference is instantiated over. More...
 
- Public Member Functions inherited from FFaReferenceBase
 FFaReferenceBase ()
 The default constructor initializes the members. More...
 
virtual ~FFaReferenceBase ()
 The destructor clears the cross references. More...
 
bool setRef (FFaFieldContainer *ptr)
 Sets the pointer value from a FFaFieldContainer pointer directly. More...
 
void setRef (int objId, int typeId)
 Sets the unresolved id and type of the referred object. More...
 
void setRef (int objId, int typeId, const IntVec &assemblyIDs)
 Sets the unresolved id and type of object in a subassembly. More...
 
bool setPointerToNull ()
 Clears the reference. More...
 
void copy (const FFaReferenceBase &aReference, bool unresolve=false)
 A copy method mostly used by FFaFieldContainer::copy(). More...
 
FFaFieldContainer * getRef () const
 Returns the FFaFieldContainer pointer contained. More...
 
bool isResolved () const
 Returns whether this reference has been resolved or not. More...
 
bool isNull () const
 Returns whether this reference points to an actual object. More...
 
void setContextName (const char *name)
 Assigns the context name for this reference. More...
 
const char * getContextName () const
 Returns the context name used by this reference. More...
 
const char * getRefTypeName () const
 Returns the type name of the referred object. More...
 
int getRefTypeID () const
 Returns the type id of the referred object. More...
 
int getRefID () const
 Returns the id number of the referred object. More...
 
bool getRefAssemblyID (IntVec &assID) const
 Returns the assembly id array of the referred object. More...
 
void setPrintIfZero (bool doPrint)
 Flags whether this reference should be printed even if NULL. More...
 
bool printMeIfZero () const
 Returns if this reference should be printed even if NULL. More...
 
void write (std::ostream &os) const
 Writes the reference to specified output stream. More...
 
void read (std::istream &is)
 Reads the reference from specified input stream. More...
 

Additional Inherited Members

- Protected Member Functions inherited from FFaReferenceBase
void resolve (FFaSearcher &findCB)
 Finds the object that has matching Type and ID as read from file. More...
 
void unresolve ()
 Does the opposite of resolve. More...
 
void updateAssemblyRef (int from, int to, size_t ind=0)
 Updates the assembly reference when moving to another assembly. More...
 
void updateAssemblyRef (const IntVec &from, const IntVec &to)
 Updates the assembly reference when moving to another assembly. More...
 
bool isEqual (const FFaReferenceBase *p) const
 Checks for equality between two references. More...
 
void bind ()
 Tells the object this reference is pointing at that it is referred. More...
 
void unbind ()
 Tells the referred object that it is not being referred anymore. More...
 
void clearResolveRef ()
 Deletes the variable used to hold temporary ID information. More...
 

Detailed Description

template<class Type>
class FFaReference< Type >

A "guarded pointer" like class.

This class can be used in classes derived from FFaFieldContainer to refer to other classes derived from FFaFieldContainer. The class can be used much like a normal pointer because of the reimplemented operators. The pointer value encapsulated by this class will automatically be set to zero if the referred object is deleted.

One of the main applications of this class is to use it together with FFaField and get automated IO of the reference. To use this feature, the FFaFieldContainer-derived class containing the reference needs a FFaField<FFaReferenceBase*> object that is initialized with the address of the FFaReference to read/write:

class FmNewClass : FFaFieldContainer
{
// ...
FFaReference<FmSomeClass> someClassReference;
FFaField<FFaReferenceBase*> someWrittenReference;
// ...
}
FmNewClass::FmNewClass()
{
// ...
// Adds field to book keeping in FFaFieldContainer Initializes
FFA_REFERENCE_FIELD_INIT(someWrittenReference, someClassReference, "FILE_KEY_WORD");
// ...
}
#define FFA_REFERENCE_FIELD_INIT(field, reference, identifier)
Adds a named reference field to *this.
Definition: FFaFieldContainer.H:258
Base class for the FEDEM model database structure.
Definition: FFaFieldContainer.H:39
A "guarded pointer" like class.
Definition: FFaReference.H:221

You can also use it as a guarded pointer outside any FFaFieldContainer. Any FFaReference can be assigned a contextName that can be used to look up why a particular reference is pointing to a FFaFieldContainer. When using the macro used above, the context name is automatically set to the same as the name of the reference. But it can be set to anything appropriate.

See also
FFaReferenceBase::setContextName

Member Function Documentation

◆ getPointer()

template<class Type >
Type* FFaReference< Type >::getPointer ( ) const
inline

Returns the type-casted pointer this reference points to.

◆ getRefClassTypeID()

template<class Type >
int FFaReference< Type >::getRefClassTypeID ( ) const
inlinefinalvirtual

Returns the class type ID this reference is instantiated over.

Reimplemented from FFaReferenceBase.

◆ operator Type *()

template<class Type >
FFaReference< Type >::operator Type * ( ) const
inline

Pointer operator.

◆ operator!=()

template<class Type >
bool FFaReference< Type >::operator!= ( const FFaReference< Type > &  p) const
inline

Inequality operator.

◆ operator*()

template<class Type >
Type& FFaReference< Type >::operator* ( ) const
inline

Dereference operator.

◆ operator->()

template<class Type >
Type* FFaReference< Type >::operator-> ( ) const
inline

Pointer operator.

◆ operator=()

template<class Type >
FFaReference<Type>& FFaReference< Type >::operator= ( Type *  ptr)
inline

Overloaded assignment operator.

◆ operator==()

template<class Type >
bool FFaReference< Type >::operator== ( const FFaReference< Type > &  p) const
inline

Equality operator.

◆ setPointer()

template<class Type >
bool FFaReference< Type >::setPointer ( Type *  ptr)
inline

Assigns ptr to this reference.


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