Safir SDK Core
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Safir::Dob::EntityInjectionBase Class Reference

This Consumer Base class contains callback methods that can be overridden by an entity handler that registers a handler for an entity type that can potentially be injected outside the control of the handler itself. More...

#include <Safir/Dob/Consumer.h>

Inheritance diagram for Safir::Dob::EntityInjectionBase:
Collaboration diagram for Safir::Dob::EntityInjectionBase:

Public Member Functions

virtual void OnInjectedNewEntity (const Safir::Dob::InjectedEntityProxy injectedEntityProxy)
 Called when a new entity is about to be injected in the system. More...
 
virtual void OnInjectedUpdatedEntity (const Safir::Dob::InjectedEntityProxy injectedEntityProxy)
 Called when an updated entity is about to be injected in the system. More...
 
virtual void OnInjectedDeletedEntity (const Safir::Dob::InjectedEntityProxy injectedEntityProxy)
 Called when an entity delete is about to be injected in the system. More...
 
virtual void OnInitialInjectionsDone (const Safir::Dob::Typesystem::TypeId typeId, const Dob::Typesystem::HandlerId &handlerId)
 Indicates that all initial injection data has been transfered to the handler. More...
 
- Public Member Functions inherited from Safir::Dob::EntityRequestBase
virtual ~EntityRequestBase ()
 Virtual destructor is needed since we have virtual member functions. More...
 
virtual void OnCreateRequest (const Safir::Dob::EntityRequestProxy entityRequestProxy, Safir::Dob::ResponseSenderPtr responseSender)=0
 Called when someone requests an entity to be created. More...
 
virtual void OnUpdateRequest (const Safir::Dob::EntityRequestProxy entityRequestProxy, Safir::Dob::ResponseSenderPtr responseSender)=0
 Called when someone requests an entity to be updated. More...
 
virtual void OnDeleteRequest (const Safir::Dob::EntityRequestProxy entityRequestProxy, Safir::Dob::ResponseSenderPtr responseSender)=0
 Called when someone requests an entity to be deleted. More...
 
- Public Member Functions inherited from Safir::Dob::Internal::ConsumerBase
virtual ~ConsumerBase ()
 

Detailed Description

This Consumer Base class contains callback methods that can be overridden by an entity handler that registers a handler for an entity type that can potentially be injected outside the control of the handler itself.

Examples of when an entity is injected outside the control of a handler includes persistent data at startup time and entities received from other system installations (multi-owned entities).

The handler can reject the injection by invoking Delete for the received entity.

In case the handler has no need to be informed when an entity is about to be injected it can rely on the default implementation which just accepts the injected entity.

An example of a situation where a handler needs to act on injected data is when the entity has members that are references (EntityIds) to other entity instances, and the lifetime of the pointed-to instance is completly connected to the lifetime of the referer. If an entity has been injected it is the responsibility of the local handler to traverse the entity instance graph, find changed references, and delete the unreferenced entity instances. To support this task there are methods in the InjectedEntityProxy class to read the previous entity state and find invalid refrences.

Another example is when an injection relates only to some of the members (might be the case when updates are received from external systems) and the handler wants to maintain some sort of consistency between different members. In this case the handler can call ConnectionAspectPostpone::IncompleteInjectionState to wait for more updates before the new state is set.

Member Function Documentation

virtual void Safir::Dob::EntityInjectionBase::OnInitialInjectionsDone ( const Safir::Dob::Typesystem::TypeId  typeId,
const Dob::Typesystem::HandlerId handlerId 
)
virtual

Indicates that all initial injection data has been transfered to the handler.

In connection to the completion of an entity registration, the Dob will transfer initial injection data to the handler. This method indicates that all such data has been transfered, and thus, enables an effective handling of the initial injection data by the handler.

This method is guaranteed to be called once for each invocation of the following methods: (This is true even when there is no initial injection data at all)

Parameters
[in]typeId- Type id in corresponding registration.
[in]handlerId- Handler id in corresponding registration.
virtual void Safir::Dob::EntityInjectionBase::OnInjectedDeletedEntity ( const Safir::Dob::InjectedEntityProxy  injectedEntityProxy)
virtual

Called when an entity delete is about to be injected in the system.

Parameters
[in]injectedEntityProxy- Proxy object containing information about the entity about to be deleted.
virtual void Safir::Dob::EntityInjectionBase::OnInjectedNewEntity ( const Safir::Dob::InjectedEntityProxy  injectedEntityProxy)
virtual

Called when a new entity is about to be injected in the system.

Parameters
[in]injectedEntityProxy- Proxy object containing entity and meta information about the new entity that is about to be injected.
virtual void Safir::Dob::EntityInjectionBase::OnInjectedUpdatedEntity ( const Safir::Dob::InjectedEntityProxy  injectedEntityProxy)
virtual

Called when an updated entity is about to be injected in the system.

Parameters
[in]injectedEntityProxy- Proxy object containing entity and meta information about the updated entity that is about to be injected.