Free Electron
Classes | Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
fe::ext::RecordView Class Referenceabstract

Bindable collection of accessor Functors. More...

#include <RecordView.h>

Inheritance diagram for fe::ext::RecordView:
Inheritance graph
[legend]

Classes

class  Functor
 Bound accessor in a RecordView. More...
 
class  RecordHolder
 Untyped Functor base. More...
 

Public Member Functions

void setName (const String &name)
 
const String verboseName (void) const
 
void bind (sp< Scope > &rspScope)
 Associate with a Scope. More...
 
void bind (hp< Scope > &rhpScope)
 Associate with a Scope by Handle. More...
 
hp< Scope > & scope (void)
 Return associated Scope. More...
 
void unbind (void)
 Disassociate with any Record. More...
 
void bind (const Record record, BWORD weak=FALSE)
 Associate with a specific Record. More...
 
void bind (const WeakRecord weakRecord, BWORD weak=FALSE)
 Associate with a specific WeakRecord. More...
 
void setWeakRecord (const WeakRecord weakRecord)
 Associate with a specific WeakRecord. More...
 
virtual void produce (Record &rRecord)
 Produce a Record using all the attributes. More...
 
virtual void finalize (Record &rRecord)
 Finalize a Record using all the attributes. More...
 
Record createRecord (void)
 Create a Record using all the attributes. More...
 
WeakRecord record (void) const
 Access the record by weak (fast) reference. More...
 
sp< Layout > layout (void)
 Access a Layout of all the attributes. More...
 
void dump (void)
 Spew attributes and state for the bound Record. More...
 
virtual void addFunctors (void)=0
 Called at instantiation to add functors. More...
 
virtual void initializeRecord (void)
 Called at instantiation to initialize attributes. More...
 
virtual void finalizeRecord (void)
 Called right after instantiation to finalize complex attributes. More...
 
void setName (const String &name)
 
const String verboseName (void) const
 
void bind (sp< Scope > &rspScope)
 Associate with a Scope. More...
 
void bind (hp< Scope > &rhpScope)
 Associate with a Scope by Handle. More...
 
hp< Scope > & scope (void)
 Return associated Scope. More...
 
void bind (const sp< RecordArray > &rspRecordArray)
 Associate with a specific RecordArray. More...
 
void unbind (void)
 Disassociate with any Record or RecordArray. More...
 
void bind (const Record record, BWORD weak=FALSE)
 Associate with a specific Record. More...
 
void bind (const WeakRecord weakRecord, BWORD weak=FALSE)
 
void setIndex (U32 index)
 Set the index into the bound RecordArray. More...
 
BWORD step (void)
 Step through the records in the array. More...
 
U32 index (void)
 Return the current index into the RecordArray. More...
 
virtual void produce (Record &rRecord)
 Produce a Record using all the attributes. More...
 
virtual void finalize (Record &rRecord)
 Finalize a Record using all the attributes. More...
 
Record createRecord (void)
 Create a Record using all the attributes. More...
 
WeakRecord record (void) const
 Access the record by weak (fast) reference. More...
 
sp< Layout > layout (void)
 Access a Layout of all the attributes. More...
 
void dump (void)
 Spew attributes and state for the bound Record. More...
 
virtual void addFunctors (void)=0
 Called at instantiation to add functors. More...
 
virtual void initializeRecord (void)
 Called at instantiation to initialize attributes. More...
 
virtual void finalizeRecord (void)
 Called right after instantiation to finalize complex attributes. More...
 
- Public Member Functions inherited from fe::AccessorSet
 AccessorSet (sp< Scope > spScope)
 
virtual FE_UWORD size (void) const
 
virtual BaseAccessoroperator[] (FE_UWORD index)
 
bool operator== (const AccessorSet &a_aset) const
 
bool operator< (const AccessorSet &a_aset) const
 
bool bind (const WeakRecord a_record)
 
void bind (sp< Scope > spScope)
 
virtual void populate (sp< Layout > spLayout)
 
void enforceHaving (const AccessorSet &a_other)
 
bool bindCheck (sp< Layout > spLayout)
 
bool check (sp< LayoutSB > spLayout)
 
bool check (sp< LayoutAV > spLayout)
 
bool bindCheck (sp< RecordArray > spRA)
 
bool check (sp< RecordArray > spRA)
 
bool check (const WeakRecord &a_record)
 
bool check (const Record &a_record)
 
void check (const WeakRecord a_record, const char *a_annotation)
 
void enforce (const String &a_ifHas)
 
void filter (sp< RecordGroup > rg_output, sp< RecordGroup > rg_input)
 
hp< Scopescope (void)
 
void filter (std::vector< Record > &a_records, sp< RecordGroup > rg_input)
 
void filter (std::vector< WeakRecord > &a_records, sp< RecordGroup > rg_input)
 
const t_bitset & bitset (void) const
 
void setBitset (const t_bitset &a_bs)
 
void add (BaseAccessor &a_accessor, const String &a_attribute)
 
void add (BaseAccessor &a_accessor)
 
void attach (const WeakRecord &a_record)
 
- Public Member Functions inherited from fe::Component
const Stringname (void) const
 Return the components chosen name. More...
 
const String verboseName (void) const
 Return the annotated chosen name. More...
 
void setName (const String &name)
 Rename the component to anything you want. More...
 
hp< Registryregistry (void) const
 Get the Registry that created this component. More...
 
void adjoin (sp< Component > spComponent)
 Tie this component's lifetime to another. More...
 
sp< Componentcreate (const String &implementation, BWORD quiet=FALSE) const
 Convienience function to registry()->create() More...
 
void disjoin (void)
 Untie component from Hub, if connected. More...
 
String factoryName (void)
 
void setLibrary (sp< Library > spLibrary)
 Store a reference to the library used to instantiate this component. More...
 
sp< Librarylibrary (void)
 Get the library that created the component. More...
 
void setFactoryIndex (I32 a_factoryIndex)
 Set the library's factory index. More...
 
I32 factoryIndex (void)
 Get the library's factory index. More...
 
void setSingleton (BWORD set)
 Specify whether component is a singleton. More...
 
BWORD isSingleton (void)
 Return whether component is a singleton. More...
 
virtual void acquire (void)
 Specialized reference increment. More...
 
virtual void release (void)
 Specialized reference decrement. More...
 
- Public Member Functions inherited from fe::Handled< Component >
const hp< Component > & getHandle (void) const
 Get a safe handle to this object. More...
 
- Public Member Functions inherited from fe::Protectable
virtual I32 protection (void) const
 
virtual void protect (void)
 
virtual void unprotect (void)
 
virtual Protectableclone (Protectable *pInstance=NULL)
 
- Public Member Functions inherited from fe::Counted
virtual void acquire (int &rCount)
 Increment the reference count (and get the count) More...
 
virtual void abandon (void)
 Decrement the reference count. More...
 
int count (void) const
 Return the count of references. More...
 
void setName (const String &)
 
void trackReference (void *pReference, String what)
 
void untrackReference (void *pReference)
 
void registerRegion (void *pT, U32 bytes)
 
- Public Member Functions inherited from fe::Initialized
void initializeAll (void)
 
void setActive (bool a_active)
 

Static Public Member Functions

template<typename T >
static void registerFactory (sp< Scope > spScope)
 Indicate a RecordFactoryI for a Scope. More...
 
static sp< RecordGrouploadRecordGroup (sp< Scope > spScope, String filename, BWORD a_binary=FALSE)
 Load a RecordGroup from a file. More...
 
static sp< RecordGrouploadRecordGroupFromBuffer (sp< Scope > spScope, String buffer, BWORD a_binary=FALSE)
 Serialize a RecordGroup from a string. More...
 
static void saveRecordGroup (sp< Scope > spScope, sp< RecordGroup > &rspRecordGroup, String filename, BWORD a_binary=FALSE)
 Save a RecordGroup to a file. More...
 
template<typename T >
static void registerFactory (sp< Scope > spScope)
 Indicate a RecordFactoryI for a Scope. More...
 
static sp< RecordGrouploadRecordGroup (sp< Scope > spScope, String filename, BWORD a_binary=FALSE)
 Load the root RecordGroup from a file. More...
 
static sp< RecordGrouploadRecordGroupFromBuffer (sp< Scope > spScope, String buffer, BWORD a_binary=FALSE)
 
static void saveRecordGroup (sp< Scope > spScope, sp< RecordGroup > &rspRecordGroup, String filename, BWORD a_binary=FALSE)
 Save the root RecordGroup to a file. More...
 
- Static Public Member Functions inherited from fe::Counted
static String reportTracker (void)
 
static U32 trackerCount (void)
 

Public Attributes

Accessor< int > count
 

Protected Member Functions

void add (BaseAccessor &rFunctor, const char *name)
 Add an attribute Functor. More...
 
 RecordView (const RecordView &rRecordView)
 
void add (BaseAccessor &rFunctor, const char *name)
 Add an attribute Functor. More...
 
- Protected Member Functions inherited from fe::Handled< Component >
void abandonHandle (void)
 
- Protected Member Functions inherited from fe::Counted
int releaseInternal (void)
 Decrement the reference count. More...
 
void suppressReport (void)
 
- Protected Member Functions inherited from fe::Initialized
void addInitializer (InitializeFunction function)
 

Private Member Functions

sp< Layout > createLayout (void)
 
String nameOf (BaseAccessor &accessor) const
 
String typeOf (BaseAccessor &accessor) const
 
String printOf (BaseAccessor &accessor)
 
sp< BaseType::Info > helpOf (BaseAccessor &accessor) const
 
sp< BaseTypebaseTypeOf (BaseAccessor &accessor) const
 
 RecordView (const RecordView &rRecordView)
 
void assignIndex (U32 index)
 
sp< Layout > createLayout (void)
 
String nameOf (BaseAccessor &accessor) const
 
String typeOf (BaseAccessor &accessor) const
 
String printOf (BaseAccessor &accessor)
 
sp< BaseType::Info > helpOf (BaseAccessor &accessor) const
 
sp< BaseTypebaseTypeOf (BaseAccessor &accessor) const
 

Private Attributes

hp< Layout > m_hpLayout
 
Record m_record
 
WeakRecord m_weakRecord
 
sp< RecordArraym_spRecordArray
 
U32 m_index
 
U32 m_nextIndex
 
BWORD m_tempArray
 

Additional Inherited Members

- Protected Types inherited from fe::Initialized
typedef void(* InitializeFunction) (Initialized *)
 
- Protected Attributes inherited from fe::AccessorSet
hp< Scopem_hpScope
 
Array< BaseAccessor * > m_accessors
 
t_bitset m_bitset
 
WeakRecord m_optional_record
 

Detailed Description

Bindable collection of accessor Functors.

RecordView is an enhanced AccessorSet that supports inheritance and default values. Like an AccessorSet, a RecordView instance can be reused for any number of Record instances.

For example:

class FE_DL_EXPORT Point: public RecordView
{
public:
Functor<SpatialVector> location;
Point(void) { setName("Point"); }
virtual void addFunctors(void)
{
add(length, "spatial_vector",
FE_SPEC("spc:at",
"translation from origin"));
}
virtual void initializeRecord(void)
{
set(location());
}
virtual void finalizeRecord(void)
{
}
};
A class that derives from RecordView is expected to provide several things.
Added attributes are provided through Functors,
an enhancement of the Accessor.

Provide a name for the generated Layout by setting the name
of the RecordView, using setName().

Functors are wired up using add() during addFunctors().
The implementation of addFunctors() should call the like-named functions
for any direct base classes, much like a manual constructor mechanism.
Convention insists that attributes names are provided using
FE_USE or FE_SPEC.  FE_USE presumes that an FE_SPEC or FE_ATTRIBUTE
elsewhere has provided a description for the atrribute.

As a RecordFactoryI, a RecordView can be used to instantiate Records
by name from file.  The method initializeRecord is called before
loading data to provide basic defaults.  A method finalizeRecord
can be used after loading a Record for producing derived values,
such as creating a component as named by an attribute.
Both initializeRecord and finalizeRecord may be omitted if
nothing needs to be done for that stage.
As with addFunctors, both initializeRecord and finalizeRecord should
call the like-named functions for any direct base classes.

To be available as a RecordFactoryI, each RecordView-derived type
should be added to a library during CreateLibrary()
like any other Component.
pLibrary->add<Point>("RecordFactoryI.Point.fe");
File-based defaults can be provided as a template in a record group file.
TEMPLATE Point ""
spc:at "0 0 0"
Attributes not represented by a template retain settings from
initializeRecord or their type's constructor.
Derived templates can provide new defaults that override prior values.
In the basic case, templates will parallel provided Factories,
including multiple inheritance (the second argument to TEMPLATE).
However, new templates can be provided purely on multiple inheritance
where no new attributes are added.

Member Function Documentation

◆ add() [1/2]

void fe::ext::RecordView::add ( BaseAccessor rFunctor,
const char *  name 
)
inlineprotected

Add an attribute Functor.

The functor should be a member variable. The name can be arbitrary, but conventions may be wise.

References fe::BaseAccessor::setup().

◆ add() [2/2]

void fe::ext::RecordView::add ( BaseAccessor rFunctor,
const char *  name 
)
inlineprotected

Add an attribute Functor.

The functor should be a member variable. The name can be arbitrary, but conventions may be wise.

References index(), and fe::BaseAccessor::setup().

◆ addFunctors() [1/2]

virtual void fe::ext::RecordView::addFunctors ( void  )
pure virtual

◆ addFunctors() [2/2]

virtual void fe::ext::RecordView::addFunctors ( void  )
pure virtual

◆ bind() [1/8]

void fe::ext::RecordView::bind ( sp< Scope > &  rspScope)
inlinevirtual

Associate with a Scope.

This can happen automatically by binding to a Record, but may be neccessary if you need to use the Functors before an appropriate Layout exists.

Implements fe::RecordFactoryI.

Referenced by fe::ext::Attractor::initializeRecord(), fe::ext::Crowd::initializeRecord(), fe::ext::Foundry::initializeRecord(), and fe::ext::Scanner::initializeRecord().

◆ bind() [2/8]

void fe::ext::RecordView::bind ( hp< Scope > &  rhpScope)
inline

Associate with a Scope by Handle.

◆ bind() [3/8]

void fe::ext::RecordView::bind ( const Record  record,
BWORD  weak = FALSE 
)
inline

Associate with a specific Record.

The Record will persist while bound. Use unbind() to release the binding.

Passing Record objects is not thread-safe.

This may use the Record's scope to initialize the functors.

◆ bind() [4/8]

void fe::ext::RecordView::bind ( sp< Scope > &  rspScope)
inlinevirtual

Associate with a Scope.

This can happen automatically by binding to a Record or RecordArray, but may be neccessary if you need to use the Functors before an appropriate Layout exists.

Implements fe::RecordFactoryI.

◆ bind() [5/8]

void fe::ext::RecordView::bind ( const WeakRecord  weakRecord,
BWORD  weak = FALSE 
)
inline

Associate with a specific WeakRecord.

The RecordView will not ensure that the WeakRecord continues to persist.

This may use the Record's scope to initialize the functors.

◆ bind() [6/8]

void fe::ext::RecordView::bind ( hp< Scope > &  rhpScope)
inline

Associate with a Scope by Handle.

◆ bind() [7/8]

void fe::ext::RecordView::bind ( const sp< RecordArray > &  rspRecordArray)
inline

Associate with a specific RecordArray.

Use setIndex() or step() to associate with each Record.

◆ bind() [8/8]

void fe::ext::RecordView::bind ( const Record  record,
BWORD  weak = FALSE 
)
inline

Associate with a specific Record.

This is only intended to be used when there is no containing RecordArray available. It can be more efficient to bind to a RecordArray and use setIndex() or step().

Passing Record objects is not thread-safe.

◆ createRecord() [1/2]

Record fe::ext::RecordView::createRecord ( void  )
inline

Create a Record using all the attributes.

The Record is automatically bound.

Referenced by produce().

◆ createRecord() [2/2]

Record fe::ext::RecordView::createRecord ( void  )
inline

Create a Record using all the attributes.

The Record is automatically bound.

◆ dump() [1/2]

void fe::ext::RecordView::dump ( void  )
inline

Spew attributes and state for the bound Record.

◆ dump() [2/2]

void fe::ext::RecordView::dump ( void  )
inline

Spew attributes and state for the bound Record.

◆ finalize() [1/2]

virtual void fe::ext::RecordView::finalize ( Record rRecord)
inlinevirtual

Finalize a Record using all the attributes.

This step follows after the record is fully initialized and potentially serialized in.

The Record is unbound after initialization.

Implements fe::RecordFactoryI.

References finalizeRecord(), fe::RecordSB::isValid(), and unbind().

◆ finalize() [2/2]

virtual void fe::ext::RecordView::finalize ( Record rRecord)
inlinevirtual

Finalize a Record using all the attributes.

This step follows after the record is fully initialized and potentially serialized in.

The Record is unbound after initialization.

Implements fe::RecordFactoryI.

References finalizeRecord(), fe::RecordSB::isValid(), and unbind().

◆ finalizeRecord() [1/2]

virtual void fe::ext::RecordView::finalizeRecord ( void  )
inlinevirtual

Called right after instantiation to finalize complex attributes.

In addition to adjusting any attributes, the implementation of this function should first call finalizeRecord() for all directly inherited classes that are indirectly or directly derived from RecordView().

Functors can be used as accessors at this point.

Reimplemented in fe::ext::SurfaceModel, fe::ext::Material, fe::ext::Executor, fe::ext::SurfacePrimitive, fe::ext::Recordable, and fe::ext::Strata.

Referenced by finalize(), fe::ext::Strata::finalizeRecord(), and fe::ext::Recordable::finalizeRecord().

◆ finalizeRecord() [2/2]

virtual void fe::ext::RecordView::finalizeRecord ( void  )
inlinevirtual

Called right after instantiation to finalize complex attributes.

In addition to adjusting any attributes, the implementation of this function should first call finalizeRecord() for all directly inherited classes that are indirectly or directly derived from RecordView().

Functors can be used as accessors at this point.

Reimplemented in fe::ext::SurfaceModel, fe::ext::Material, fe::ext::Executor, fe::ext::SurfacePrimitive, fe::ext::Recordable, and fe::ext::Strata.

◆ index()

U32 fe::ext::RecordView::index ( void  )
inline

Return the current index into the RecordArray.

Referenced by add(), and setIndex().

◆ initializeRecord() [1/2]

virtual void fe::ext::RecordView::initializeRecord ( void  )
inlinevirtual

◆ initializeRecord() [2/2]

virtual void fe::ext::RecordView::initializeRecord ( void  )
inlinevirtual

◆ layout() [1/2]

sp<Layout> fe::ext::RecordView::layout ( void  )
inlinevirtual

Access a Layout of all the attributes.

Implements fe::RecordFactoryI.

◆ layout() [2/2]

sp<Layout> fe::ext::RecordView::layout ( void  )
inlinevirtual

Access a Layout of all the attributes.

Implements fe::RecordFactoryI.

◆ loadRecordGroup() [1/2]

static sp<RecordGroup> fe::ext::RecordView::loadRecordGroup ( sp< Scope spScope,
String  filename,
BWORD  a_binary = FALSE 
)
inlinestatic

Load a RecordGroup from a file.

This is a convenience that doesn't really relate to RecordView.

◆ loadRecordGroup() [2/2]

static sp<RecordGroup> fe::ext::RecordView::loadRecordGroup ( sp< Scope spScope,
String  filename,
BWORD  a_binary = FALSE 
)
inlinestatic

Load the root RecordGroup from a file.

This is a convenience that doesn't really relate to RecordView.

◆ loadRecordGroupFromBuffer()

static sp<RecordGroup> fe::ext::RecordView::loadRecordGroupFromBuffer ( sp< Scope spScope,
String  buffer,
BWORD  a_binary = FALSE 
)
inlinestatic

Serialize a RecordGroup from a string.

This is a convenience that doesn't really relate to RecordView.

◆ produce() [1/2]

virtual void fe::ext::RecordView::produce ( Record rRecord)
inlinevirtual

Produce a Record using all the attributes.

The Record is unbound after initialization.

Implements fe::RecordFactoryI.

References createRecord(), initializeRecord(), fe::RecordSB::isValid(), and unbind().

◆ produce() [2/2]

virtual void fe::ext::RecordView::produce ( Record rRecord)
inlinevirtual

Produce a Record using all the attributes.

The Record is unbound after initialization.

Implements fe::RecordFactoryI.

References createRecord(), initializeRecord(), fe::RecordSB::isValid(), and unbind().

◆ record() [1/2]

WeakRecord fe::ext::RecordView::record ( void  ) const
inline

Access the record by weak (fast) reference.

Referenced by fe::ext::RecordView::Functor< T >::call().

◆ record() [2/2]

WeakRecord fe::ext::RecordView::record ( void  ) const
inline

Access the record by weak (fast) reference.

◆ registerFactory() [1/2]

template<typename T >
static void fe::ext::RecordView::registerFactory ( sp< Scope spScope)
inlinestatic

Indicate a RecordFactoryI for a Scope.

The template type is presumably a RecordView. This function extracts the relevant arguments to pass to the Scope.

It is usually preferable to add the RecordView as a Scope-generic RecordFactoryI using the general registry mechanism.

This is a convenience that doesn't really relate to RecordView.

References fe::Scope::registerFactory().

◆ registerFactory() [2/2]

template<typename T >
static void fe::ext::RecordView::registerFactory ( sp< Scope spScope)
inlinestatic

Indicate a RecordFactoryI for a Scope.

The template type is presumably a RecordView. This function extracts the relevant arguments to pass to the Scope.

It is usually preferable to add the RecordView as a Scope-generic RecordFactoryI using the general registry mechanism.

This is a convenience that doesn't really relate to RecordView.

References fe::Scope::registerFactory().

◆ saveRecordGroup() [1/2]

static void fe::ext::RecordView::saveRecordGroup ( sp< Scope spScope,
sp< RecordGroup > &  rspRecordGroup,
String  filename,
BWORD  a_binary = FALSE 
)
inlinestatic

Save a RecordGroup to a file.

This is a convenience that doesn't really relate to RecordView.

◆ saveRecordGroup() [2/2]

static void fe::ext::RecordView::saveRecordGroup ( sp< Scope spScope,
sp< RecordGroup > &  rspRecordGroup,
String  filename,
BWORD  a_binary = FALSE 
)
inlinestatic

Save the root RecordGroup to a file.

This is a convenience that doesn't really relate to RecordView.

◆ scope() [1/2]

hp<Scope>& fe::ext::RecordView::scope ( void  )
inline

Return associated Scope.

◆ scope() [2/2]

hp<Scope>& fe::ext::RecordView::scope ( void  )
inline

Return associated Scope.

◆ setIndex()

void fe::ext::RecordView::setIndex ( U32  index)
inline

Set the index into the bound RecordArray.

The first step() after setIndex() does not increment the index.

References index().

◆ setWeakRecord()

void fe::ext::RecordView::setWeakRecord ( const WeakRecord  weakRecord)
inline

Associate with a specific WeakRecord.

The RecordView will not ensure that the WeakRecord continues to persist.

This method is faster than bind(WeakRecord) as it will never check the Scope and initialize the functors. Using bind(sp<Scope>) before this method can ensure that the functors are initialized.

Referenced by fe::ext::RecordArrayView< fe::ext::Matter >::at().

◆ step()

BWORD fe::ext::RecordView::step ( void  )
inline

Step through the records in the array.

The first step will stay on the first record. Later steps increment the index. Stepping past the last record will return FALSE.

In the future, filters may allow step() to skip records.

◆ unbind() [1/2]

void fe::ext::RecordView::unbind ( void  )
inline

Disassociate with any Record.

This should free all references.

Referenced by finalize(), and produce().

◆ unbind() [2/2]

void fe::ext::RecordView::unbind ( void  )
inline

Disassociate with any Record or RecordArray.

This should free all references.


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