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

Dictionary of Arbitrary Instances. More...

#include <Catalog.h>

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

Public Member Functions

sp< CatalogcatalogShallowCopy (void)
 Returns a mirror of the catalog. More...
 
sp< CatalogcatalogDeepCopy (void)
 Returns a duplicate of the catalog. More...
 
U32 catalogSize (void) const
 Returns the number of name keys. More...
 
String catalogKey (U32 index) const
 Returns a key by ordered index. More...
 
void catalogKeys (Array< String > &a_keys, String a_pattern=".*") const
 Returns keys in order of creation. More...
 
void catalogProperties (String a_name, Array< String > &a_properties) const
 Returns properties for a key. More...
 
BWORD cataloged (String a_name, String a_property="value") const
 Returns TRUE if the given property for the given name has been created. More...
 
BWORD catalogedAny (String a_name) const
 Returns TRUE if any property for the given name has been created. More...
 
void catalogClear (void)
 Remove all entries. More...
 
void catalogOverlay (sp< Catalog > a_spOtherCatalog, Array< String > *a_pTypeList=NULL, BWORD a_shallow=FALSE)
 Duplicates entries from another catalog. More...
 
sp< ComponentcatalogComponent (String implementation, String a_name, String a_property="value")
 Returns a component entry of the given property for the given name. More...
 
sp< ComponentcatalogComponent (sp< Component > a_spComponent, String a_name, String a_property="value")
 Returns a component entry of the given property for the given name. More...
 
InstancecatalogInstance (Instance &instance, String a_name, String a_property="value")
 Returns the literal Instance of the given property for the given name. More...
 
InstancecatalogInstance (String a_name, String a_property="value")
 Returns the literal Instance of the given property for the given name. More...
 
const fe_type_info & catalogTypeInfo (String a_name, String a_property="value") const
 Returns the type_info of the given property for the given name. More...
 
const String catalogTypeName (String a_name, String a_property="value") const
 Returns the type name of the given property, determined by the TypeMaster. More...
 
template<class T >
BWORD catalogTypeIs (String a_name, String a_property="value") const
 Returns TRUE if given catalog entry match the template type. More...
 
template<class T >
T & catalog (String a_name, String a_property="value")
 Returns existing catalog entry if already set or a default if not. More...
 
template<class T >
T & catalog (String a_name, String a_property, const T &a_default)
 Returns existing catalog entry if already set or default if not. More...
 
template<class T >
const T & catalogOrDefault (String a_name, String a_property, const T &a_default) const
 Returns existing catalog entry if already set or default if not. More...
 
template<class T >
const T & catalogOrDefault (String a_name, const T &a_default) const
 
String catalogValue (String a_name, String a_property="value") const
 Returns existing catalog entry, converted to a String. More...
 
I32 catalogBytes (String a_name, String a_property, Array< U8 > &a_rByteArray) const
 Converts a catalog entry, into raw binary. More...
 
BWORD catalogSet (String a_name, String a_property, String a_value)
 Sets the value for a catalog entry, converted to the existing type, from a given String. More...
 
BWORD catalogSet (String a_name, String a_value)
 
BWORD catalogSet (String a_name, String a_property, String a_type, String a_value, Instance **a_ppInstance=NULL)
 Sets the value for a catalog entry, converted to the existing type, from a given String. More...
 
BWORD catalogSet (String a_name, String a_property, String a_type, const U8 *a_pRawBytes, I32 a_byteCount, Instance **a_ppInstance=NULL)
 Sets the value for a catalog entry, using a raw byte block. More...
 
template<class T >
T & catalogOrException (String a_name, String a_property) const
 Returns an existing catalog entry, if it exists. More...
 
bool catalogLookup (const String a_name, String a_property, Instance &a_instance) const
 Gets the Instance of an existing catalog entry, if it exists. More...
 
bool catalogLookup (const String a_name, Instance &a_instance) const
 
void catalogMoveToEnd (String a_name)
 Move all properties for name to bottom. More...
 
void catalogRemove (String a_name)
 Remove all properties for a name. More...
 
void catalogRemove (String a_name, String a_property)
 Remove one property for a name. More...
 
void catalogDump (void) const
 Print a description of the catalog to the log. More...
 
sp< TypeMastertypeMaster (void) const
 
- 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 Member Functions

template<class T >
T & createInstance (String a_name, String a_property="value")
 

Private Attributes

std::map< String, InstanceMapm_instanceMapMap
 
std::map< I32, Stringm_orderMap
 
I32 m_highest
 

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

Dictionary of Arbitrary Instances.

TODO allow reordering TODO allow individual removal (remember to also remove from order map)

Member Function Documentation

◆ catalog() [1/2]

template<class T >
T & fe::Catalog::catalog ( String  a_name,
String  a_property = "value" 
)

Returns existing catalog entry if already set or a default if not.

If entry does not exist, this version will create an entry and set it to the appropriate Type default.

The default property is 'value'.

Referenced by fe::ext::NetHost::accessSpace(), and fe::ext::NetHost::hasSpace().

◆ catalog() [2/2]

template<class T >
T & fe::Catalog::catalog ( String  a_name,
String  a_property,
const T &  a_default 
)

Returns existing catalog entry if already set or default if not.

If entry does not exist, this version will create an entry and set it to the given default.

◆ catalogBytes()

I32 fe::Catalog::catalogBytes ( String  a_name,
String  a_property,
Array< U8 > &  a_rByteArray 
) const

Converts a catalog entry, into raw binary.

Returns the number of bytes in the buffer.

If entry does not exist, zero bytes is returned.

◆ catalogClear()

void fe::Catalog::catalogClear ( void  )
inline

Remove all entries.

◆ catalogComponent() [1/2]

sp< Component > fe::Catalog::catalogComponent ( String  implementation,
String  a_name,
String  a_property = "value" 
)

Returns a component entry of the given property for the given name.

If the entry does not exist, it may be created using the given implementation name.

The return value will be invalid if the implementation could not be instantiated.

◆ catalogComponent() [2/2]

sp< Component > fe::Catalog::catalogComponent ( sp< Component a_spComponent,
String  a_name,
String  a_property = "value" 
)
inline

Returns a component entry of the given property for the given name.

Regardless of whether the entry previously existed, it is replaced by the given Component.

The default property if 'value'.

◆ catalogDeepCopy()

sp< Catalog > fe::Catalog::catalogDeepCopy ( void  )

Returns a duplicate of the catalog.

All values are also copied by assignment.

◆ catalogDump()

void fe::Catalog::catalogDump ( void  ) const

Print a description of the catalog to the log.

◆ cataloged()

BWORD fe::Catalog::cataloged ( String  a_name,
String  a_property = "value" 
) const
inline

Returns TRUE if the given property for the given name has been created.

The default property is 'value'.

◆ catalogedAny()

BWORD fe::Catalog::catalogedAny ( String  a_name) const
inline

Returns TRUE if any property for the given name has been created.

◆ catalogInstance() [1/2]

Instance & fe::Catalog::catalogInstance ( Instance instance,
String  a_name,
String  a_property = "value" 
)
inline

Returns the literal Instance of the given property for the given name.

Regardless of whether the entry previously existed, it is replaced by the given Instance.

The default property is 'value'.

Referenced by fe::StateCatalog::overlayState().

◆ catalogInstance() [2/2]

Instance & fe::Catalog::catalogInstance ( String  a_name,
String  a_property = "value" 
)
inline

Returns the literal Instance of the given property for the given name.

If the entry does not exist, it will be created.

The default property is 'value'.

◆ catalogKey()

String fe::Catalog::catalogKey ( U32  index) const

Returns a key by ordered index.

By default, keys are index in creation order.

◆ catalogKeys()

void fe::Catalog::catalogKeys ( Array< String > &  a_keys,
String  a_pattern = ".*" 
) const

Returns keys in order of creation.

Keys are appended to the given array. Clear the array if only want new values.

If a regex pattern is given, only matching keys are returned.

Future improvements may allow reordering.

References fe::String::c_str().

Referenced by fe::StateCatalog::getStateKeys(), and fe::StateCatalog::overlayState().

◆ catalogLookup()

bool fe::Catalog::catalogLookup ( const String  a_name,
String  a_property,
Instance a_instance 
) const

Gets the Instance of an existing catalog entry, if it exists.

If entry does not exist, the method return false.

The default property is 'value'.

◆ catalogMoveToEnd()

void fe::Catalog::catalogMoveToEnd ( String  a_name)
inline

Move all properties for name to bottom.

◆ catalogOrDefault()

template<class T >
const T & fe::Catalog::catalogOrDefault ( String  a_name,
String  a_property,
const T &  a_default 
) const

Returns existing catalog entry if already set or default if not.

If entry does not exist, this version will not create an entry and simply return the given default.

The default property is 'value'.

◆ catalogOrException()

template<class T >
T & fe::Catalog::catalogOrException ( String  a_name,
String  a_property 
) const

Returns an existing catalog entry, if it exists.

If entry does not exist, this version will throw an exception.

The default property is 'value'.

◆ catalogOverlay()

void fe::Catalog::catalogOverlay ( sp< Catalog a_spOtherCatalog,
Array< String > *  a_pTypeList = NULL,
BWORD  a_shallow = FALSE 
)

Duplicates entries from another catalog.

Optionally, a list of type names limits which entries are copied.

◆ catalogProperties()

void fe::Catalog::catalogProperties ( String  a_name,
Array< String > &  a_properties 
) const

Returns properties for a key.

Properties are appended to the given array. Clear the array if only want new values.

Order is arbitrary.

Referenced by fe::StateCatalog::getStateProperties(), fe::StateCatalog::overlayState(), and fe::StateCatalog::removeState().

◆ catalogRemove() [1/2]

void fe::Catalog::catalogRemove ( String  a_name)
inline

Remove all properties for a name.

Referenced by fe::StateCatalog::removeState().

◆ catalogRemove() [2/2]

void fe::Catalog::catalogRemove ( String  a_name,
String  a_property 
)
inline

Remove one property for a name.

◆ catalogSet() [1/3]

BWORD fe::Catalog::catalogSet ( String  a_name,
String  a_property,
String  a_value 
)

Sets the value for a catalog entry, converted to the existing type, from a given String.

If entry does not exist, it is not created.

The default property is 'value'.

◆ catalogSet() [2/3]

BWORD fe::Catalog::catalogSet ( String  a_name,
String  a_property,
String  a_type,
String  a_value,
Instance **  a_ppInstance = NULL 
)

Sets the value for a catalog entry, converted to the existing type, from a given String.

If entry does not exist, it is created using the named type.

If the Instance pointer pointer is not null. the contained pointer is set to point to the instance. This can save the time of immediately doing another map lookup, if you need the instance.

◆ catalogSet() [3/3]

BWORD fe::Catalog::catalogSet ( String  a_name,
String  a_property,
String  a_type,
const U8 *  a_pRawBytes,
I32  a_byteCount,
Instance **  a_ppInstance = NULL 
)

Sets the value for a catalog entry, using a raw byte block.

If entry does not exist, it is created.

If the Instance pointer pointer is not null. the contained pointer is set to point to the instance. This can save the time of immediately doing another map lookup, if you need the instance.

◆ catalogShallowCopy()

sp< Catalog > fe::Catalog::catalogShallowCopy ( void  )

Returns a mirror of the catalog.

All values shared references with the original.

◆ catalogSize()

U32 fe::Catalog::catalogSize ( void  ) const

Returns the number of name keys.

Each name key may have any number of properties.

◆ catalogTypeInfo()

const fe_type_info & fe::Catalog::catalogTypeInfo ( String  a_name,
String  a_property = "value" 
) const
inline

Returns the type_info of the given property for the given name.

If the entry does not exist, it will be created.

The default property is 'value'.

◆ catalogTypeIs()

template<class T >
BWORD fe::Catalog::catalogTypeIs ( String  a_name,
String  a_property = "value" 
) const
inline

Returns TRUE if given catalog entry match the template type.

◆ catalogTypeName()

const String fe::Catalog::catalogTypeName ( String  a_name,
String  a_property = "value" 
) const
inline

Returns the type name of the given property, determined by the TypeMaster.

If the entry does not exist, it will be created.

The default property is 'value'.

Referenced by fe::StateCatalog::getTypeName(), and fe::StateCatalog::getTypeNameUnsafe().

◆ catalogValue()

String fe::Catalog::catalogValue ( String  a_name,
String  a_property = "value" 
) const

Returns existing catalog entry, converted to a String.

If entry does not exist, an empty String is returned.

The default property is 'value'.


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