Sen API
Sen Libraries
Loading...
Searching...
No Matches
native_object_proxy.h
Go to the documentation of this file.
1// === native_object_proxy.h ===========================================================================================
2// Sen Infrastructure
3// Released under the Apache License v2.0 (SPDX-License-Identifier Apache-2.0).
4// See the LICENSE.txt file for more information.
5// © Airbus SAS, Airbus Helicopters, and Airbus Defence and Space SAU/GmbH/SAS.
6// =====================================================================================================================
7
8#ifndef SEN_CORE_OBJ_DETAIL_NATIVE_OBJECT_PROXY_H
9#define SEN_CORE_OBJ_DETAIL_NATIVE_OBJECT_PROXY_H
10
11// sen
16#include "sen/core/meta/type.h"
20
21// std
22#include <mutex>
23
24namespace sen
25{
26
27// Forward declarations
28class NativeObject;
29
30namespace impl
31{
32
34class SEN_EXPORT NativeObjectProxy: public ProxyObject
35{
36 SEN_NOCOPY_NOMOVE(NativeObjectProxy)
37
38public: // special members
39 NativeObjectProxy(NativeObject* owner, std::string_view localPrefix);
40 ~NativeObjectProxy() override = default;
41
42public: // implements Object
43 [[nodiscard]] ObjectId getId() const noexcept final;
44 [[nodiscard]] const std::string& getName() const noexcept final;
45 [[nodiscard]] ConstTypeHandle<ClassType> getClass() const noexcept override;
46 [[nodiscard]] const ProxyObject* asProxyObject() const noexcept final;
47 [[nodiscard]] ProxyObject* asProxyObject() noexcept final;
48 [[nodiscard]] RemoteObject* asRemoteObject() noexcept final;
49 [[nodiscard]] const RemoteObject* asRemoteObject() const noexcept final;
50 [[nodiscard]] const std::string& getLocalName() const noexcept final;
51 [[nodiscard]] TimeStamp getLastCommitTime() const noexcept final;
52 [[nodiscard]] ConnectionGuard onEventUntyped(const Event* ev, EventCallback<VarList>&& callback) final;
53 [[nodiscard]] ConnectionGuard onPropertyChangedUntyped(const Property* prop, EventCallback<VarList>&& callback) final;
54 void invokeAllPropertyCallbacks() final;
55
56 // NOLINTNEXTLINE
57 void invokeUntyped(const Method* method, const VarList& args, MethodCallback<Var>&& onDone = {}) final;
58 [[nodiscard]] Var getPropertyUntyped(const Property* prop) const final;
59 void drainInputs() override;
60 bool isRemote() const noexcept final;
61
62protected: // called by the generated code
63 void sendWork(std::function<void()>&& work, bool forcePush) const;
64 virtual void drainInputsImpl(TimeStamp lastCommitTime) = 0;
65 [[nodiscard]] virtual Var senImplGetPropertyImpl(MemberHash propertyId) const = 0;
66 [[nodiscard]] ConnId senImplMakeConnectionId() const noexcept;
67 void senImplEventEmitted(MemberHash id, std::function<VarList()>&& argsGetter, const EventInfo& info) final;
68 void removeTypedConnectionOnOwner(ConnId connId);
69 void senImplRemoveUntypedConnection(ConnId id, MemberHash memberHash) override;
70
71private:
72 struct EventCallbackData
73 {
74 uint32_t id;
75 EventCallback<VarList> callback;
76 };
77
78 using EventCallbackList = std::vector<EventCallbackData>;
79
80 struct EventData
81 {
82 EventCallbackList list;
83 TransportMode transportMode;
84 };
85
86 using EventCallbackMap = std::unordered_map<MemberHash, EventData>;
87
88private:
89 NativeObject* owner_;
90 std::shared_ptr<Object> guard_;
91 std::string localName_;
92 TimeStamp lastCommitTime_;
93 std::unique_ptr<EventCallbackMap> eventCallbacks_;
94 std::recursive_mutex eventCallbacksMutex_;
95};
96
97} // namespace impl
98
99} // namespace sen
100
101#endif // SEN_CORE_OBJ_DETAIL_NATIVE_OBJECT_PROXY_H
An object instantiated in this process. This is the base class for all user-implemented objects.
Definition native_object.h:63
TransportMode
How to transport information.
Definition type.h:56
Definition assert.h:17