Safir SDK Core
Loading...
Searching...
No Matches
ConnectionBase.h
Go to the documentation of this file.
1/******************************************************************************
2*
3* Copyright Saab AB, 2007-2013, 2023 (http://safirsdkcore.com)
4*
5* Created by: Anders Widén / stawi
6*
7*******************************************************************************
8*
9* This file is part of Safir SDK Core.
10*
11* Safir SDK Core is free software: you can redistribute it and/or modify
12* it under the terms of version 3 of the GNU General Public License as
13* published by the Free Software Foundation.
14*
15* Safir SDK Core is distributed in the hope that it will be useful,
16* but WITHOUT ANY WARRANTY; without even the implied warranty of
17* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18* GNU General Public License for more details.
19*
20* You should have received a copy of the GNU General Public License
21* along with Safir SDK Core. If not, see <http://www.gnu.org/licenses/>.
22*
23******************************************************************************/
24
25#ifndef _SAFIR_DOB_CONNECTION_BASE_H
26#define _SAFIR_DOB_CONNECTION_BASE_H
27
28#include <Safir/Dob/Consumer.h>
29#include <Safir/Dob/Defs.h>
31#include <Safir/Dob/Entity.h>
33#include <Safir/Dob/Message.h>
34#include <Safir/Dob/Response.h>
35#include <Safir/Dob/Service.h>
40
41#ifndef SAFIR_NO_BOOST
43#endif
44
45namespace Safir
46{
47namespace Dob
48{
49 //forward declaration
50 class EntityIterator;
51
59 {
60 public:
61
66
70 virtual ~ConnectionBase();
71
77 virtual bool IsOpen() const = 0;
78
108 const Dob::Typesystem::HandlerId& handlerId,
109 const Dob::InstanceIdPolicy::Enumeration instanceIdPolicy,
110 Dob::EntityHandler* const entityHandler) const;
111
139 const Dob::Typesystem::HandlerId& handlerId,
140 const Dob::InstanceIdPolicy::Enumeration instanceIdPolicy,
141 Dob::EntityHandlerInjection* const entityHandlerInjection) const;
176 const Dob::Typesystem::HandlerId& handlerId,
177 const Dob::InstanceIdPolicy::Enumeration instanceIdPolicy,
178 Dob::EntityHandlerPending* const entityHandlerPending) const;
179
199 const Dob::Typesystem::HandlerId& handlerId,
200 Dob::ServiceHandler* const serviceHandler) const;
201
221 const Dob::Typesystem::HandlerId& handlerId,
222 Dob::ServiceHandlerPending* const serviceHandlerPending) const;
249 const Dob::Typesystem::HandlerId& handlerId) const;
250
275 const Dob::Typesystem::ChannelId& channelId,
276 Dob::MessageSubscriber* const messageSubscriber) const;
277
293 const Dob::Typesystem::ChannelId& channelId,
294 const bool includeSubclasses,
295 Dob::MessageSubscriber* const messageSubscriber) const;
296
318 const Dob::Typesystem::ChannelId& channelId,
319 Dob::MessageSubscriber* const messageSubscriber) const;
320
337 const Dob::Typesystem::ChannelId& channelId,
338 const bool includeSubclasses,
339 Dob::MessageSubscriber* const messageSubscriber) const;
340
341
365 Dob::EntitySubscriber* const entitySubscriber) const;
366
385 const bool includeUpdates,
386 const bool includeSubclasses,
387 const bool restartSubscription,
388 Dob::EntitySubscriber* const entitySubscriber) const;
389
406 const bool includeUpdates,
407 const bool restartSubscription,
408 Dob::EntitySubscriber* const entitySubscriber) const;
409
424 Dob::EntitySubscriber* const entitySubscriber) const;
425
441 const bool includeSubclasses,
442 Dob::EntitySubscriber* const entitySubscriber) const;
443
456 Dob::EntitySubscriber* const entitySubscriber) const;
489 const Dob::Typesystem::HandlerId& handlerId,
490 const bool includeSubclasses,
491 const bool restartSubscription,
492 Dob::RegistrationSubscriber* const registrationSubscriber) const;
493
512 const Dob::Typesystem::HandlerId& handlerId,
513 const bool includeSubclasses,
514 Dob::RegistrationSubscriber* const registrationSubscriber) const;
537 void Send(const Dob::MessagePtr& message,
538 const Dob::Typesystem::ChannelId& channelId,
539 Dob::MessageSender* const messageSender) const;
540
573 const Dob::Typesystem::HandlerId& handlerId,
574 Dob::Requestor* const requestor) const;
575
605 const Dob::Typesystem::InstanceId& instanceId,
606 const Dob::Typesystem::HandlerId& handlerId,
607 Dob::Requestor* const requestor) const;
608
629 const Dob::Typesystem::InstanceId& instanceId,
630 Dob::Requestor* const requestor) const;
631
651 Dob::Requestor* const requestor) const;
652
671 const Dob::Typesystem::HandlerId& handlerId,
672 Dob::Requestor* const requestor) const;
673
696 void SetChanges(const Dob::EntityPtr& entity,
697 const Dob::Typesystem::InstanceId& instanceId,
698 const Dob::Typesystem::HandlerId& handlerId) const;
699
720 void SetAll(const Dob::EntityPtr& entity,
721 const Dob::Typesystem::InstanceId& instanceId,
722 const Dob::Typesystem::HandlerId& handlerId) const;
723
736 void Delete(const Dob::Typesystem::EntityId& entityId,
737 const Dob::Typesystem::HandlerId& handlerId) const;
738
750 const Dob::Typesystem::HandlerId& handlerId) const;
751
779 const bool includeSubclasses) const;
780
799 const Dob::EntityProxy Read(const Dob::Typesystem::EntityId & entityId) const;
800
816 bool IsCreated(const Dob::Typesystem::EntityId & entityId) const;
817
829 const Dob::Typesystem::HandlerId& handlerId,
830 const bool includeSubclasses) const;
831
843 const Dob::Typesystem::HandlerId& handlerId) const;
844
857 void ExitDispatch() const;
858
861 private:
862 //Disable copying and assignment
864 ConnectionBase& operator=(const ConnectionBase& rhs);
865
867
868 virtual DotsC_Int32 GetControllerId() const = 0;
869
870 void Set(const Dob::EntityPtr& entity,
871 const Dob::Typesystem::InstanceId& instanceId,
872 const Dob::Typesystem::HandlerId& handlerId,
873 const bool considerChangeFlags) const;
874 };
875
876}
877}
878
879#endif
#define DOSE_CPP_API
Definition DoseCppExportDefs.h:33
This namespace contains all the functionality and definitions of the SAFIR SDK.
Definition Backdoor.h:31
std::shared_ptr< Message > MessagePtr
Definition Message.h:34
std::shared_ptr< Service > ServicePtr
Definition Service.h:34
Safir::Dob::Typesystem::Int32 RequestId
Represents the id of a request.
Definition Defs.h:42
std::shared_ptr< Entity > EntityPtr
Definition Entity.h:34
DotsC_Int64 Int64
64 bit integer type.
Definition Defs.h:69
DotsC_TypeId TypeId
A unique type identifier.
Definition Defs.h:218
Base class for all aspects.
Definition ConnectionAspectBase.h:38
Common base class for connections to the DOB.
Definition ConnectionBase.h:59
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).
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.
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).
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.
ConnectionBase()
Constructor.
void UnsubscribeEntity(const Dob::Typesystem::TypeId typeId, Dob::EntitySubscriber *const entitySubscriber) const
Remove an entity subscription made by the given subscriber.
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.
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.
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.
void ExitDispatch() const
Interrupt the ongoing Dispatch even if all data to the application have not been distpatched.
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 t...
Dob::EntityIterator GetEntityIterator(const Dob::Typesystem::TypeId typeId, const bool includeSubclasses) const
Retreives an STL compliant iterator to iterate over created instances.
virtual bool IsOpen() const =0
Tells if the connection is opened.
const Dob::EntityProxy Read(const Dob::Typesystem::EntityId &entityId) const
Read an entity from the distributed object pool.
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.
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).
virtual ~ConnectionBase()
Destructor.
void SubscribeEntity(const Dob::Typesystem::TypeId typeId, Dob::EntitySubscriber *const entitySubscriber) const
Set up subscription for instances of an entity type and its subclasses.
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.
void DeleteAllInstances(const Dob::Typesystem::TypeId typeId, const Dob::Typesystem::HandlerId &handlerId) const
Allows an entity handler to delete all owned instances.
void Send(const Dob::MessagePtr &message, const Dob::Typesystem::ChannelId &channelId, Dob::MessageSender *const messageSender) const
Send a message on the specified channel.
void UnsubscribeEntity(const Dob::Typesystem::EntityId &entityId, Dob::EntitySubscriber *const entitySubscriber) const
Remove an entity instance subscription made by the given subscriber.
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.
Dob::RequestId DeleteRequest(const Dob::Typesystem::EntityId &entityId, Dob::Requestor *const requestor) const
Send a delete request on an existing entity instance.
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.
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.
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.
bool IsCreated(const Dob::Typesystem::EntityId &entityId) const
Check if an instance of an entity is created or not.
void UnregisterHandler(const Dob::Typesystem::TypeId typeId, const Dob::Typesystem::HandlerId &handlerId) const
Unregister of an entity handler or a service handler.
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.
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.
void UnsubscribeRegistration(const Dob::Typesystem::TypeId typeId, const Dob::Typesystem::HandlerId &handlerId, const bool includeSubclasses, Dob::RegistrationSubscriber *const registrationSubscriber) const
Removes a registration subscription.
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).
void Delete(const Dob::Typesystem::EntityId &entityId, const Dob::Typesystem::HandlerId &handlerId) const
Allows an entity handler to delete a specific owned entity instance.
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.
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.
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).
Interface to be implemented by an entity handler that makes a non-pending registration and that doesn...
Definition Consumer.h:115
Interface to be implemented by an entity handler that makes a non-pending registration for a type tha...
Definition Consumer.h:155
Interface to be implemented by an entity handler that makes a pending registration.
Definition Consumer.h:197
Interface to be implemented by a service handler that makes a non-pending registration.
Definition Consumer.h:218
Interface to be implemented by a service handler that makes a pending registration.
Definition Consumer.h:242
Interface to be implemented by an application that sends requests (Request on entities or service req...
Definition Consumer.h:254
Interface to be implemented by senders of messages.
Definition Consumer.h:280
Interface to be implemented by subscribers of handler registrations.
Definition Consumer.h:299
Interface to be implemented by subscribers of messages.
Definition Consumer.h:331
Interface to be implemented by subscribers of entities.
Definition Consumer.h:352
A STL conformant forward iterator used to traverse entity instances.
Definition EntityIterator.h:47
Proxy class for an entity.
Definition EntityProxy.h:54
Class containing the identity of a channel.
Definition ChannelId.h:46
Class containing the identity of an entity.
Definition EntityId.h:43
Class containing the identity of a handler.
Definition HandlerId.h:46
Class containing the identity of an instance.
Definition InstanceId.h:49
Enumeration
Definition InstanceIdPolicy.h:37