Free Electron
Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
fe::Scope Class Reference

Layout namespace. More...

#include <Scope.h>

Inheritance diagram for fe::Scope:
Inheritance graph
[legend]

Public Member Functions

 Scope (void)
 Create a scope from within the fe::Registry. More...
 
 Scope (Master &master)
 Construct a Scope bound to the the TypeMaster and Allocator within master. More...
 
 Scope (sp< Master > &spMaster)
 
 Scope (sp< TypeMaster > spTypeMaster, sp< Allocator > allocator)
 Construct a Scope bound to the given TypeMaster and Allocator. More...
 
 Scope (const Scope &other)
 
Scopeoperator= (const Scope &other)
 
virtual void setName (const String &name)
 
void initialize (void)
 Post construction step (last chance to find Master) More...
 
void layoutValidate (void)
 Validate that there are no dependency conflicts and remove dependency duplicates. More...
 
void setLocking (BWORD a_locking)
 Specify if select methods should be protected with a mutex. More...
 
BWORD isLocking (void)
 
sp< Layout > declare (const String &name)
 Declare a new layout. More...
 
sp< Layout > lookupLayout (const String &name)
 Lock a layout. More...
 
void registerFactory (String name, sp< RecordFactoryI > spRecordFactoryI)
 Specify who can produce a named layout. More...
 
Record produceRecord (String name)
 Create and return a new Record from registered RecordFactoryI. More...
 
void finalize (Record &rRecord)
 Run post-initialization on Record using registered RecordFactoryI. More...
 
Record createRecord (sp< Layout > spLayout)
 Create and return a new Record of layout spLayout. More...
 
Record createRecord (const String layout)
 
sp< RecordArraycreateRecordArray (String layout, FE_UWORD count)
 Create and return a new RecordArray of layout spLayout. More...
 
sp< RecordArraycreateRecordArray (sp< Layout > spLayout, FE_UWORD count)
 
sp< AttributeaddDepend (sp< Depend > &depend)
 Free the given record. More...
 
FE_UWORD getAttributeCount (void) const
 Return the total number of Attributes in this Scope. More...
 
sp< Attribute > & findAttribute (const String &name, FE_UWORD &index)
 Return the Attribute with the given name. More...
 
sp< Attribute > & findAttribute (const String &name)
 Return the Attribute with the given name. More...
 
sp< Attributeattribute (FE_UWORD index)
 Return the Attribute at the given index. More...
 
FE_UWORD attributeIndex (sp< Attribute > spAttribute)
 Return the index of the given Attribute. More...
 
sp< Attributesupport (const String &mayHave, const String &ofType)
 Add a support for a Attribute with name and type of name ofType. More...
 
bool enforce (const String &ifHas, const String &mustHave)
 Enforce a Attribute dependency. More...
 
bool enforce (const Array< String > &ifHas, const String &mustHave)
 
bool populate (const String &ifIs, const String &mustHave)
 Add a Attribute to a Layout. More...
 
bool share (const String &ifIs, const String &share1, const String &share2)
 Clear all populate dependencies for Layout of name name. More...
 
void clonePopulate (const String &ifThisHas, const String &thenThisDoes)
 
sp< TypeMastertypeMaster (void)
 Return the associated TypeMaster. More...
 
Accessor< std::atomic< int > > & refCount (void)
 Return an Accessor for the Record reference count Attribute. More...
 
void resizeLayoutLocators (void) const
 
void peek (Peeker &peeker)
 For debugging. More...
 
U32 serialIndex (void)
 
template<typename R >
void assignIDNumber (const R &record)
 
template<typename R >
void freeIDNumber (const R &r_old)
 
FE_UWORD getNextUniqueLayoutID (void)
 
FE_UWORD getNextUniqueIDR (void)
 
void addAccessorSet (AccessorSet *a_as)
 
void removeAccessorSet (AccessorSet *a_as)
 
t_attributesattributes (void)
 Direct access to the attribute table. More...
 
t_layoutslayouts (void)
 Direct access to the layout table. More...
 
t_dependsdepends (void)
 Direct access to the depend list. More...
 
sp< Allocator > allocator (void)
 Direct access to the allocator. More...
 
sp< RecordCookbookcookbook (void)
 
- 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)
 

Private Types

typedef HashMap< String, sp< RecordFactoryI >, hash_string, eq_string > StringRecordFactoryMap
 

Private Member Functions

bool shutdown (void)
 Release references to all Layout, Depend, and Store instances. More...
 
void construct (sp< TypeMaster > spTypeMaster, sp< Allocator > allocator)
 
void prepareCookbook (sp< Master > &rspMaster)
 
void depAttributeCheck (sp< Depend > &depend)
 
void depRecordCheck (sp< Depend > &depend)
 
sp< AttributedynamicAddAttribute (const String &typeName, const String &attributeName)
 
sp< AttributeaddAttribute (const String &typeName, const String &attributeName)
 
void notifyLayoutsOfAttributeChange (sp< Depend > &depend)
 
StringStringsMap & factoryMultiMap (void)
 

Private Attributes

sp< TypeMasterm_spTypeMaster
 
t_layouts m_layouts
 
t_attributes m_attributes
 
t_indexmap m_indexmap
 
t_depends m_depend
 
sp< Allocator > m_spAllocator
 
sp< RecordCookbookm_spRecordCookbook
 
std::set< AccessorSet * > m_accessorSets
 
bool m_looking
 
bool m_locking
 
I32 m_serialCount
 
U32 m_serialIndex
 
Accessor< std::atomic< int > > * m_paCount
 
Accessor< std::atomic< int > > * m_paSerialNumber
 
hp< Registrym_hpRegistry
 
String m_storeName
 
StringRecordFactoryMap m_factoryMap
 
sp< Attributem_nullAttribute
 
FE_UWORD m_nextUniqueLayoutID
 
FE_UWORD m_nextUniqueIDR
 

Additional Inherited Members

- Static Public Member Functions inherited from fe::Counted
static String reportTracker (void)
 
static U32 trackerCount (void)
 
- Protected Types inherited from fe::Initialized
typedef void(* InitializeFunction) (Initialized *)
 
- 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)
 

Detailed Description

Layout namespace.

Every Layout must be associated with a single Scope. Every Record layout is defined by a single Layout, therefore every Record is associated with a single Scope.

Scope is therefore the main class for state based activity. Records are defined (via Layout), created, and destroyed using Scope.

direct accessors
:CT
:CT
:CT
:CT
:ID
:ID
:SN
:SN
:CT
:SN

Constructor & Destructor Documentation

◆ Scope() [1/3]

fe::Scope::Scope ( void  )

Create a scope from within the fe::Registry.

This function will assert if called outside the registry which supplies the fe::Master information.

◆ Scope() [2/3]

fe::Scope::Scope ( Master master)

Construct a Scope bound to the the TypeMaster and Allocator within master.

◆ Scope() [3/3]

fe::Scope::Scope ( sp< TypeMaster spTypeMaster,
sp< Allocator >  allocator 
)

Construct a Scope bound to the given TypeMaster and Allocator.

Member Function Documentation

◆ addDepend()

sp< Attribute > fe::Scope::addDepend ( sp< Depend > &  depend)

Free the given record.

This will throw an Exception if record is reference counted. All records with the Attribute FE_C are reference counted. This is the default for all records (Scope has populate("", FE_C) in its constructor). Add a dependency. This is mainly for internal use by support, enforce, populate, and share.

Referenced by enforce(), populate(), share(), and support().

◆ allocator()

sp< Allocator > fe::Scope::allocator ( void  )
inline

Direct access to the allocator.

Use with care.

◆ attribute()

sp< Attribute > fe::Scope::attribute ( FE_UWORD  index)

Return the Attribute at the given index.

◆ attributeIndex()

FE_UWORD fe::Scope::attributeIndex ( sp< Attribute spAttribute)

Return the index of the given Attribute.

Todo:
cache m_index in Attribute itself for O(1) lookup

◆ attributes()

t_attributes & fe::Scope::attributes ( void  )
inline

Direct access to the attribute table.

Use with care.

◆ createRecord()

Record fe::Scope::createRecord ( sp< Layout >  spLayout)

Create and return a new Record of layout spLayout.

Referenced by fe::ext::NullViewer::run().

◆ createRecordArray()

sp< RecordArray > fe::Scope::createRecordArray ( String  layout,
FE_UWORD  count 
)

Create and return a new RecordArray of layout spLayout.

References lookupLayout().

Referenced by fe::ext::StratumDrawPoly::assignVisibility().

◆ declare()

sp< Layout > fe::Scope::declare ( const String name)

Declare a new layout.

This will create an empty and unlocked layout.

An empty layout name is not permitted (an invalid sp<> would be returned).

Referenced by fe::ext::NetworkCatalog::start().

◆ depends()

t_depends & fe::Scope::depends ( void  )
inline

Direct access to the depend list.

Use with care.

◆ enforce()

bool fe::Scope::enforce ( const String ifHas,
const String mustHave 
)

Enforce a Attribute dependency.

If a Layout has a Attribute named ifHas, it will also have a Attribute of name mustHave.

References addDepend().

◆ finalize()

void fe::Scope::finalize ( Record rRecord)

Run post-initialization on Record using registered RecordFactoryI.

References fe::RecordSB::layout().

◆ findAttribute() [1/2]

sp< Attribute > & fe::Scope::findAttribute ( const String name,
FE_UWORD &  index 
)

Return the Attribute with the given name.

The index of the Attribute is returned in index.

Referenced by findAttribute(), fe::BaseAccessor::initialize(), and fe::BaseAccessor::setup().

◆ findAttribute() [2/2]

sp< Attribute > & fe::Scope::findAttribute ( const String name)

Return the Attribute with the given name.

References findAttribute().

◆ getAttributeCount()

FE_UWORD fe::Scope::getAttributeCount ( void  ) const

Return the total number of Attributes in this Scope.

Referenced by fe::RecordGroup::removeReferences().

◆ initialize()

void fe::Scope::initialize ( void  )

Post construction step (last chance to find Master)

References fe::hp< T >::isValid(), and fe::Component::registry().

◆ layouts()

t_layouts & fe::Scope::layouts ( void  )
inline

Direct access to the layout table.

Use with care.

◆ layoutValidate()

void fe::Scope::layoutValidate ( void  )

Validate that there are no dependency conflicts and remove dependency duplicates.

This is mainly for internal use.

◆ lookupLayout()

sp< Layout > fe::Scope::lookupLayout ( const String name)

Lock a layout.

Finalize the structure that the layout represents. This must happen before records of this layout are created. If not done before a call to createRecord or createRecordArray then the layout is automatically locked upon these calls. Return the layout with the given name

This first attempts to lookup an existing Layout. If that fails, it will then try to instantiate a layout from a RecordFactoryI registered under the same name.

If no layout is found, an invalid sp<> is returned.

Referenced by fe::ext::ObjectViewer::bind(), and createRecordArray().

◆ peek()

void fe::Scope::peek ( Peeker &  peeker)

For debugging.

◆ populate()

bool fe::Scope::populate ( const String ifIs,
const String mustHave 
)

Add a Attribute to a Layout.

If a Layout is named ifIs, then it will have a Attribute of name mustHave.

References addDepend().

Referenced by share().

◆ produceRecord()

Record fe::Scope::produceRecord ( String  name)

Create and return a new Record from registered RecordFactoryI.

◆ refCount()

Accessor< std::atomic< int > > & fe::Scope::refCount ( void  )

Return an Accessor for the Record reference count Attribute.

◆ registerFactory()

void fe::Scope::registerFactory ( String  name,
sp< RecordFactoryI spRecordFactoryI 
)

Specify who can produce a named layout.

References fe::Component::name().

Referenced by fe::ext::RecordView::registerFactory().

◆ setLocking()

void fe::Scope::setLocking ( BWORD  a_locking)
inline

Specify if select methods should be protected with a mutex.

◆ share()

bool fe::Scope::share ( const String ifIs,
const String share1,
const String share2 
)

Clear all populate dependencies for Layout of name name.

Specify a Attribute share. This means that two Attributes will actually be the same instance (same piece of memory) for a particular Layout. If a Layout is named ifIs, then treat Attributes of names share1 and share2 as the same.

References addDepend(), and populate().

◆ shutdown()

bool fe::Scope::shutdown ( void  )
private

Release references to all Layout, Depend, and Store instances.

This may be necessary to break dependency cycles.

Todo:
create and reference dependency graph

◆ support()

sp< Attribute > fe::Scope::support ( const String mayHave,
const String ofType 
)

Add a support for a Attribute with name and type of name ofType.

References addDepend().

Referenced by fe::BaseAccessor::setup().

◆ typeMaster()

sp< TypeMaster > fe::Scope::typeMaster ( void  )
inline

Return the associated TypeMaster.

Referenced by fe::RecordGroup::removeReferences().


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