COROIO: coroio/actors/actorid.hpp Source File
COROIO
 
Loading...
Searching...
No Matches
actorid.hpp
1#pragma once
2
3namespace NNet {
4namespace NActors {
5
7using TLocalActorId = uint32_t;
8
10using TNodeId = uint16_t;
11
13using TCookie = uint16_t;
14
16using TMessageId = uint32_t;
17
26class TActorId {
27public:
29 TActorId() = default;
30
35 operator bool() const {
36 return !((NodeId_ == 0) & (ActorId_ == 0) & (Cookie_ == 0));
37 }
38
40 TNodeId NodeId() const {
41 return NodeId_;
42 }
43
46 TLocalActorId ActorId() const {
47 return ActorId_;
48 }
49
51 TCookie Cookie() const {
52 return Cookie_;
53 }
54
59 std::string ToString() const {
60 return "ActorId:"
61 + std::to_string(NodeId_) + ":"
62 + std::to_string(ActorId_) + ":"
63 + std::to_string(Cookie_);
64 }
65
72 TActorId(TNodeId nodeId, TLocalActorId actorId, TCookie cookie)
73 : NodeId_(nodeId)
74 , ActorId_(actorId)
75 , Cookie_(cookie)
76 { }
77
78private:
79 TLocalActorId ActorId_ = 0;
80 TNodeId NodeId_ = 0;
81 TCookie Cookie_ = 0;
82};
83
88struct THeader {
89 TActorId Sender;
90 TActorId Recipient;
91 TMessageId MessageId = 0;
92 uint32_t Size = 0;
93};
94
95} // namespace NActors
96} // namespace NNet
Unique identifier for actors in the system.
Definition actorid.hpp:26
TNodeId NodeId() const
Get the node ID component.
Definition actorid.hpp:40
TCookie Cookie() const
Get the cookie component.
Definition actorid.hpp:51
TActorId()=default
Default constructor creates an invalid actor ID.
TActorId(TNodeId nodeId, TLocalActorId actorId, TCookie cookie)
Construct actor ID with specific components.
Definition actorid.hpp:72
std::string ToString() const
Convert actor ID to string representation.
Definition actorid.hpp:59
TLocalActorId ActorId() const
Get the local actor ID component.
Definition actorid.hpp:46
Header for messages sent between actors. Used in remote communication and serialization.
Definition actorid.hpp:88