Safir SDK Core
|
A connection to the DOB. More...
#include <Safir/Dob/Connection.h>
Public Member Functions | |
Connection () | |
Constructor. More... | |
virtual | ~Connection () |
Destructor. More... | |
void | Open (const std::wstring &connectionNameCommonPart, const std::wstring &connectionNameInstancePart, const Dob::Typesystem::Int32 context, StopHandler *const stopHandler, Dispatcher *const dispatcher) |
Open a connection to the DOB. More... | |
void | Close () |
Close the connection to the DOB. More... | |
virtual bool | IsOpen () const |
Check if this Connection instance is open. More... | |
void | Dispatch () const |
When the dispatch event or callback is signalled, the application MUST call this method. More... | |
Public Member Functions inherited from Safir::Dob::ConnectionBase | |
ConnectionBase () | |
Constructor. More... | |
virtual | ~ConnectionBase () |
Destructor. More... | |
void | RegisterEntityHandler (const Safir::Dob::Typesystem::TypeId typeId, const Dob::Typesystem::HandlerId &handlerId, const Dob::InstanceIdPolicy::Enumeration instanceIdPolicy, Dob::EntityHandler *const entityHandler) const |
Registration of an entity handler for a given type. More... | |
void | RegisterEntityHandlerInjection (const Safir::Dob::Typesystem::TypeId typeId, const Dob::Typesystem::HandlerId &handlerId, const Dob::InstanceIdPolicy::Enumeration instanceIdPolicy, Dob::EntityHandlerInjection *const entityHandlerInjection) const |
Register an entity handler that also gets informed about injected entities. More... | |
void | RegisterEntityHandlerPending (const Dob::Typesystem::TypeId typeId, const Dob::Typesystem::HandlerId &handlerId, const Dob::InstanceIdPolicy::Enumeration instanceIdPolicy, Dob::EntityHandlerPending *const entityHandlerPending) const |
Pending registration of a handler for a given entity type. More... | |
void | RegisterServiceHandler (const Safir::Dob::Typesystem::TypeId typeId, const Dob::Typesystem::HandlerId &handlerId, Dob::ServiceHandler *const serviceHandler) const |
Register a service handler for a given type. More... | |
void | RegisterServiceHandlerPending (const Dob::Typesystem::TypeId typeId, const Dob::Typesystem::HandlerId &handlerId, Dob::ServiceHandlerPending *const serviceHandlerPending) const |
Pending registration of a handler for a given service type. More... | |
void | UnregisterHandler (const Dob::Typesystem::TypeId typeId, const Dob::Typesystem::HandlerId &handlerId) const |
Unregister of an entity handler or a service handler. More... | |
void | SubscribeMessage (const Dob::Typesystem::TypeId typeId, const Dob::Typesystem::ChannelId &channelId, Dob::MessageSubscriber *const messageSubscriber) const |
Set up subscription for messages of a certain type and its subclasses. More... | |
void | SubscribeMessage (const Dob::Typesystem::TypeId typeId, const Dob::Typesystem::ChannelId &channelId, const bool includeSubclasses, Dob::MessageSubscriber *const messageSubscriber) const |
Set up subscription for messages of a certain type (additional parameters). More... | |
void | UnsubscribeMessage (const Dob::Typesystem::TypeId typeId, const Dob::Typesystem::ChannelId &channelId, Dob::MessageSubscriber *const messageSubscriber) const |
Remove a message subscription made by the given subscriber. More... | |
void | UnsubscribeMessage (const Dob::Typesystem::TypeId typeId, const Dob::Typesystem::ChannelId &channelId, const bool includeSubclasses, Dob::MessageSubscriber *const messageSubscriber) const |
Remove a message subscription made by the given subscriber (additional parameters). More... | |
void | SubscribeEntity (const Dob::Typesystem::TypeId typeId, Dob::EntitySubscriber *const entitySubscriber) const |
Set up subscription for instances of an entity type and its subclasses. More... | |
void | SubscribeEntity (const Dob::Typesystem::TypeId typeId, const bool includeUpdates, const bool includeSubclasses, const bool restartSubscription, Dob::EntitySubscriber *const entitySubscriber) const |
Subscription for an entity type (additional parameters). More... | |
void | SubscribeEntity (const Dob::Typesystem::EntityId &entityId, const bool includeUpdates, const bool restartSubscription, Dob::EntitySubscriber *const entitySubscriber) const |
Set up subscription for a specific instance of an entity type. More... | |
void | UnsubscribeEntity (const Dob::Typesystem::TypeId typeId, Dob::EntitySubscriber *const entitySubscriber) const |
Remove an entity subscription made by the given subscriber. More... | |
void | UnsubscribeEntity (const Dob::Typesystem::TypeId typeId, const bool includeSubclasses, Dob::EntitySubscriber *const entitySubscriber) const |
Remove an entity subscription made by the given subscriber (additional parameters). More... | |
void | UnsubscribeEntity (const Dob::Typesystem::EntityId &entityId, Dob::EntitySubscriber *const entitySubscriber) const |
Remove an entity instance subscription made by the given subscriber. More... | |
void | SubscribeRegistration (const Dob::Typesystem::TypeId typeId, const Dob::Typesystem::HandlerId &handlerId, const bool includeSubclasses, const bool restartSubscription, Dob::RegistrationSubscriber *const registrationSubscriber) const |
Set up subscription for notifications about when a specific handler for an entity type or a service type is registered and unregistered. More... | |
void | UnsubscribeRegistration (const Dob::Typesystem::TypeId typeId, const Dob::Typesystem::HandlerId &handlerId, const bool includeSubclasses, Dob::RegistrationSubscriber *const registrationSubscriber) const |
Removes a registration subscription. More... | |
void | Send (const Dob::MessagePtr &message, const Dob::Typesystem::ChannelId &channelId, Dob::MessageSender *const messageSender) const |
Send a message on the specified channel. More... | |
Dob::RequestId | CreateRequest (const Dob::EntityPtr &request, const Dob::Typesystem::HandlerId &handlerId, Dob::Requestor *const requestor) const |
Request to a handler to create an entity instance without specifying the instanceId. More... | |
Dob::RequestId | CreateRequest (const Dob::EntityPtr &request, const Dob::Typesystem::InstanceId &instanceId, const Dob::Typesystem::HandlerId &handlerId, Dob::Requestor *const requestor) const |
Request to a handler to create a specific entity instance. More... | |
Dob::RequestId | UpdateRequest (const Dob::EntityPtr &request, const Dob::Typesystem::InstanceId &instanceId, Dob::Requestor *const requestor) const |
Send an update request on an existing entity instance. More... | |
Dob::RequestId | DeleteRequest (const Dob::Typesystem::EntityId &entityId, Dob::Requestor *const requestor) const |
Send a delete request on an existing entity instance. More... | |
Dob::RequestId | ServiceRequest (const Dob::ServicePtr &request, const Dob::Typesystem::HandlerId &handlerId, Dob::Requestor *const requestor) const |
Send a request to the given service handler. More... | |
void | SetChanges (const Dob::EntityPtr &entity, const Dob::Typesystem::InstanceId &instanceId, const Dob::Typesystem::HandlerId &handlerId) const |
Merge the changed members of an entity straight into the pool (the given handler must be the owner). More... | |
void | SetAll (const Dob::EntityPtr &entity, const Dob::Typesystem::InstanceId &instanceId, const Dob::Typesystem::HandlerId &handlerId) const |
Allows an entity handler to create or update an entity. More... | |
void | Delete (const Dob::Typesystem::EntityId &entityId, const Dob::Typesystem::HandlerId &handlerId) const |
Allows an entity handler to delete a specific owned entity instance. More... | |
void | DeleteAllInstances (const Dob::Typesystem::TypeId typeId, const Dob::Typesystem::HandlerId &handlerId) const |
Allows an entity handler to delete all owned instances. More... | |
Dob::EntityIterator | GetEntityIterator (const Dob::Typesystem::TypeId typeId, const bool includeSubclasses) const |
Retreives an STL compliant iterator to iterate over created instances. More... | |
const Dob::EntityProxy | Read (const Dob::Typesystem::EntityId &entityId) const |
Read an entity from the distributed object pool. More... | |
bool | IsCreated (const Dob::Typesystem::EntityId &entityId) const |
Check if an instance of an entity is created or not. More... | |
Dob::Typesystem::Int64 | GetNumberOfInstances (const Dob::Typesystem::TypeId typeId, const Dob::Typesystem::HandlerId &handlerId, const bool includeSubclasses) const |
This method is used to get the number of instances of an entity that exists. More... | |
Dob::InstanceIdPolicy::Enumeration | GetInstanceIdPolicy (const Dob::Typesystem::TypeId typeId, const Dob::Typesystem::HandlerId &handlerId) const |
This method is used to get the instanceIdPolicy for a specific class and handler. More... | |
void | ExitDispatch () const |
Interrupt the ongoing Dispatch even if all data to the application have not been distpatched. More... | |
A connection to the DOB.
This class represents a "real" (as opposed to SecondaryConnection) connection to the dob. Each DOB application must have at least one connection. Connections are not thread safe.
Safir::Dob::Connection::Connection | ( | ) |
Constructor.
|
virtual |
Destructor.
void Safir::Dob::Connection::Close | ( | ) |
Close the connection to the DOB.
Closes the connection to the DOB and deallocates all resources. All subscriptions and registrations will automatically be deleted and there is no need to call Unsubscribe and Unregister before calling Close. Note that all connections that were set up using Attach will also be closed after a call to this method.
void Safir::Dob::Connection::Dispatch | ( | ) | const |
When the dispatch event or callback is signalled, the application MUST call this method.
A call to Dispatch will result in that all queues for this connection are emptied and that each message in the queues are passed to the associated consumer. Calls to dispatch from connection instances that are not open will be ignored.
|
virtual |
Check if this Connection instance is open.
Implements Safir::Dob::ConnectionBase.
void Safir::Dob::Connection::Open | ( | const std::wstring & | connectionNameCommonPart, |
const std::wstring & | connectionNameInstancePart, | ||
const Dob::Typesystem::Int32 | context, | ||
StopHandler *const | stopHandler, | ||
Dispatcher *const | dispatcher | ||
) |
Open a connection to the DOB.
The connection uses the OnDoDispatch callback to signal that there is incoming data available. When OnDoDispatch is called the application shall set an event or similar and then call Dispatch() in this class from the thread that owns (has called Open) the connection.
There can be a number of contexts in the DOB. A connection is linked to the context specified in Open. All operations using a connection is affecting only the context linked to that connection. The intended primary usage is for recording/replay functionality. 0 is defined as the default context.
Note that connectionNameCommonPart together with connectionNameInstancePart must be unique in the node.
If NULL is passed as the stopHandler argument the connection will not receive a stop order. Normally only the main thread of an application should pass a non-NULL stopHandler, and it should then tell other parts of the application to exit. If multiple stop handlers are specified there is NO guaranteed order between which gets called first when a process receives a stop signal.
[in] | connectionNameCommonPart | Name that identifies the program but not any particular program instance. |
[in] | connectionNameInstancePart | Name that identifies a particular program instance. |
[in] | context | Context |
[in] | stopHandler | Object that implements the StopHandler interface. |
[in] | dispatcher | Object that implements the Dispatcher interface. |
Safir::Dob::NotOpenException | The connection name is already used by someone else. Try another! |