Free Electron
|
StateCatalog with connected mirroring. More...
#include <ConnectedCatalog.h>
Public Member Functions | |
void | initialize (void) |
virtual Result | configure (String a_line) override |
Provide a parsable setup string. More... | |
virtual Result | start (void) override |
Initiate connections. More... | |
virtual Result | stop (void) override |
Disconnect and stop initiating connections. More... | |
virtual Result | waitForConnection (void) override |
Return only after a connection has been made. More... | |
virtual BWORD | started (void) const override |
Check if the catalog wants to connect. More... | |
virtual BWORD | connected (void) const override |
Check if the catalog has connections. More... | |
virtual void | setConnectionTimeout (Real a_seconds) |
Indicate how long the server may remain quiet. More... | |
virtual Result | flush (void) override |
Indicate the end of an atomic set of changes. More... | |
virtual Result | waitForUpdate (I32 &a_rFlushCount, I32 &a_rSpins, volatile BWORD &a_rKeepWaiting, I32 a_microSleep) override |
Wait for a state change. More... | |
virtual Result | lockAfterUpdate (I32 &a_rFlushCount, I32 &a_rSpins, volatile BWORD &a_rKeepWaiting, I32 a_microSleep) override |
Wait for a state change and then lock the mutex. More... | |
Public Member Functions inherited from fe::StateCatalog | |
Result | getTypeName (String a_name, String &a_rTypeName) const |
Get state with mutex (default property) More... | |
Result | getTypeName (String a_name, String a_property, String &a_rTypeName) const |
Get state with mutex. More... | |
void | getStateKeys (Array< String > &a_keys, String a_pattern=".*") const |
Returns keys that match the regex pattern. More... | |
void | getStateProperties (String a_name, Array< String > &a_properties) const |
Returns properties for a key. More... | |
template<class T > | |
Result | getState (String a_name, T &a_rValue) const |
Get state with mutex (default property) More... | |
template<class T > | |
Result | getState (String a_name, String a_property, T &a_rValue) const |
Get state with mutex. More... | |
Result | getState (String a_name, String a_property, String &a_rTypeName, String &a_rValue) const |
template<class T > | |
Result | justGetState (String a_name, String a_property, T &a_rValue) const |
Get state with mutex, but without calling the internal preGet() and postGet() methods. More... | |
template<class T > | |
Result | setState (String a_name, const T &a_rValue) |
Set state with mutex (default property) More... | |
template<class T > | |
Result | setState (String a_name, String a_property, const T &a_rValue) |
Set state with mutex. More... | |
Result | setState (String a_name, String a_property, String a_typeName, String a_value) |
Set state with mutex (serialized) More... | |
Result | removeState (String a_name, String a_property) |
Remove a state, with mutex. More... | |
Result | removeState (String a_name) |
Remove all properties of a state, with mutex. More... | |
Result | overlayState (sp< Catalog > a_spOtherCatalog) |
Set state for entries in a Catalog, with mutex. More... | |
Result | getTypeNameUnsafe (String a_name, String &a_rTypeName) const |
Get state without mutex. More... | |
Result | getTypeNameUnsafe (String a_name, String a_property, String &a_rTypeName) const |
Get state without mutex (default property) More... | |
template<class T > | |
Result | getStateUnsafe (String a_name, T &a_rValue) const |
Get state without mutex. More... | |
template<class T > | |
Result | getStateUnsafe (String a_name, String a_property, T &a_rValue) const |
Get state without mutex (default property) More... | |
Result | snapshot (sp< Snapshot > &a_rspSnapshot) |
Grab current state into a fixed snapshot. More... | |
void | incrementSerial (void) |
Increment the serial index, indicating a collective change of state. More... | |
void | incrementFlushCount (void) |
Increment the count of incoming flushes indicating a collective remote change of state. More... | |
template<class T > | |
Result | sendMessage (String a_name, const T &a_rValue) |
Append value to remote queues. More... | |
template<class T > | |
Result | nextMessage (String a_name, T &a_rValue) |
Pop received value from front of queue. More... | |
Result | addListener (sp< ListenerI > a_spListener, String a_name) |
Add a ListenerI for a specific key. More... | |
template<> | |
Result | nextMessage (String a_name, String &a_rValue) |
Public Member Functions inherited from fe::Catalog | |
sp< Catalog > | catalogShallowCopy (void) |
Returns a mirror of the catalog. More... | |
sp< Catalog > | catalogDeepCopy (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< Component > | catalogComponent (String implementation, String a_name, String a_property="value") |
Returns a component entry of the given property for the given name. More... | |
sp< Component > | catalogComponent (sp< Component > a_spComponent, String a_name, String a_property="value") |
Returns a component entry of the given property for the given name. More... | |
Instance & | catalogInstance (Instance &instance, String a_name, String a_property="value") |
Returns the literal Instance of the given property for the given name. More... | |
Instance & | catalogInstance (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< TypeMaster > | typeMaster (void) const |
Public Member Functions inherited from fe::Component | |
const String & | name (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< Registry > | registry (void) const |
Get the Registry that created this component. More... | |
void | adjoin (sp< Component > spComponent) |
Tie this component's lifetime to another. More... | |
sp< Component > | create (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< Library > | library (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 Protectable * | clone (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) |
Protected Types | |
enum | Command { e_unknown =0, e_update, e_signal, e_remove } |
Protected Types inherited from fe::Initialized | |
typedef void(* | InitializeFunction) (Initialized *) |
Protected Member Functions | |
virtual Result | preGet (String a_name, String a_property) const override |
virtual Result | postSet (String a_name, String a_property) override |
virtual Result | connect (void) |
virtual Result | disconnect (void) |
virtual Result | dropConnection (void) |
virtual Result | connectAsServer (String a_address, U16 a_port) |
virtual Result | connectAsClient (String a_address, U16 a_port) |
virtual void | broadcastUpdate (String a_name, String a_property) |
virtual void | heartbeat (void) |
virtual void | service (void) |
virtual void | broadcastSelect (String a_name, String a_property, String a_message, I32 a_includeCount, const String *a_pIncludes, I32 a_excludeCount, const String *a_pExcludes, const U8 *a_pRawBytes=NULL, I32 a_byteCount=0)=0 |
virtual BWORD | useBinaryForType (String a_type) const |
void | broadcastMessage (String a_name, String a_message) |
void | broadcastTick (void) |
void | timerRestart (void) |
BWORD | timerReached (void) const |
Real | timerSeconds (void) const |
void | tickerRestart (void) |
BWORD | tickerReached (void) const |
Real | tickerSeconds (void) const |
const String & | role (void) const |
bool | aborting (void) const |
void | requestDisconnect (void) |
bool | disconnecting (void) const |
void | stall (void) const |
void | microPause (I32 a_microSeconds) const |
void | yield (void) const |
void | serviceYield (void) const |
void | queueRepeat (Command a_command, String a_name, String a_property, String a_message, String a_source, U8 *a_pRawBytes, I32 a_byteCount) |
Result | flushRepeats (BWORD a_signalsOnly) |
void | update (Command a_command, String a_source, String a_key, String a_property, String a_type, String a_text, const U8 *a_pRawBytes=NULL, I32 a_byteCount=0) |
virtual Result | removeIdentity (I32 a_index) |
virtual Result | removeIdentity (const Identity &a_rIdentity) |
Result | catchUpAsNeeded (void) |
virtual Result | catchUp (Identity &a_rIdentity) |
Protected Member Functions inherited from fe::StateCatalog | |
virtual Result | postGet (String a_name, String a_property) const |
virtual Result | preSet (String a_name, String a_property) |
I32 | serial (void) const |
I32 | flushCount (void) const |
Result | addNotification (String a_name, String a_property) |
Result | sendNotifications (void) |
Result | notify (String a_name, String a_property) |
template<class T > | |
Result | updateState (String a_name, String a_property, const T &a_rValue) |
Result | updateState (String a_name, String a_property, String a_typeName, String a_value) |
Result | updateState (String a_name, String a_property, String a_typeName, const U8 *a_pRawBytes, I32 a_byteCount) |
Result | clearState (String a_name, String a_property) |
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) |
Protected Attributes | |
Identity | m_identityArray [FE_CNC_MAX_CLIENTS] |
I32 | m_identityCount |
BWORD | m_lockOnUpdate |
Private Member Functions | |
void | joinThreads (void) |
Private Attributes | |
Result | m_connectionResult |
Thread * | m_pConnectionThread |
ConnectionTask | m_connectionTask |
Thread * | m_pServiceThread |
ServiceTask | m_serviceTask |
String | m_role |
String | m_clientID |
String | m_listenKey |
std::atomic< int > | m_signalsQueued |
std::atomic< bool > | m_started |
std::atomic< bool > | m_connected |
std::atomic< bool > | m_aborting |
std::atomic< bool > | m_disconnecting |
Array< KeyProperty > | m_flushKeys |
Array< KeyMessage > | m_flushMessages |
Array< Change > | m_changes |
std::map< String, Array< KeyProperty > > | m_repeatQueueMap |
std::chrono::steady_clock::time_point | m_timerStart |
Real | m_timerLimit |
std::chrono::steady_clock::time_point | m_tickerStart |
Real | m_tickerLimit |
RecursiveMutex | m_startStopMutex |
Additional Inherited Members | |
Static Public Member Functions inherited from fe::Counted | |
static String | reportTracker (void) |
static U32 | trackerCount (void) |
Related Functions inherited from fe::Component | |
FE_DL_EXPORT void FE_CDECL | checkUnload (sp< Library > &pLibrary, Component *pComponent=NULL) |
Delete the component and unload libraries where appropriate. More... | |
StateCatalog with connected mirroring.
Before starting a connection, several Catalog values may need to be set. In the short form, the configure method can set up the connection with a single parsable string, such as:
"localhost:7890 role=client connectionBlock=true"
The first argument in the address and port. For a server, the address is ignored, although the convention is to just use "*".
The remaining arguments are name/value pairs. The current list a recognized values are as follows:
role "server" or "client" address string address for a client to connect to port integer port number ioPriority usually "normal" or "high" (for Windows only) transport "tcp" or "udp", where appropriate connectionBlock "true" or "false", to block flushes before connection
In the long form, the internal catalog settings can be written and read directly. The long form keys used in the catalog match the short form names, but with a "net:" prefix.
"net:role" should be set to either "server" or "client".
"net:address" should be set to the string address for a client to connect to. This is ignored for a server.
"net:port" should be set to the integer port number.
"net:ioPriority" can be set to a string, usually either "normal" or "high". The additional values are "idle", "lowest", "low", "highest", and "critical". Currently, this only has effect when using the stdthread module under Windows.
"net:transport" can be set to "tcp" or "udp", if appropriate for the implementation.
"net:connectionBlock" can be set to "true" or "false", whether to block flushes when waiting for a connection.
Provide a parsable setup string.
Reimplemented from fe::StateCatalog.
References fe::String::empty().
|
inlineoverridevirtual |
Check if the catalog has connections.
A catalog with connections is always started.
Reimplemented from fe::StateCatalog.
|
overridevirtual |
Indicate the end of an atomic set of changes.
This may provoke a transmission of buffered data.
Receiving connections should use this to increment the StateCatalog flush count and make a new Snapshot available.
Reimplemented from fe::StateCatalog.
Reimplemented in fe::ext::NetworkCatalog.
References fe::failure(), and fe::StateCatalog::flush().
Referenced by fe::ext::NetworkCatalog::flush().
|
overridevirtual |
Wait for a state change and then lock the mutex.
This method is generally only used by specialized mechanisms, since the Atomic and Snapshot classes neatly present this functionality.
See the Atomic constructor for parameter description.
Reimplemented from fe::StateCatalog.
References fe::failure().
|
overrideprotectedvirtual |
Reimplemented from fe::StateCatalog.
References fe::String::empty().
|
overrideprotectedvirtual |
Reimplemented from fe::StateCatalog.
References fe::failure(), and fe::StateCatalog::preGet().
|
virtual |
Indicate how long the server may remain quiet.
If the server has a gap between flushes exceeding this time limit, the clients may drop the connection. They may try to reconnect with the current connection settings.
Reimplemented from fe::StateCatalog.
|
overridevirtual |
Initiate connections.
A server will begin seeking client connections and a client will try to make a connection. This method may return before making any connections.
Implements fe::StateCatalog.
Reimplemented in fe::ext::NetworkCatalog.
Referenced by fe::ext::NetworkCatalog::start().
|
inlineoverridevirtual |
Check if the catalog wants to connect.
The started state means the catalog is seeking connections. A started catlog may have connections.
Reimplemented from fe::StateCatalog.
|
overridevirtual |
Disconnect and stop initiating connections.
New connections will no longer be accepted.
This method will not return until the connections existing connections are disconnected.
Implements fe::StateCatalog.
|
overridevirtual |
Return only after a connection has been made.
A derived implementation could return a failure result code, indicating a problem prior to making a connection.
Reimplemented from fe::StateCatalog.
|
overridevirtual |
Wait for a state change.
This method is generally only used by specialized mechanisms, since the Atomic and Snapshot classes neatly present this functionality.
See the Atomic constructor for parameter description.
Reimplemented from fe::StateCatalog.