Roboid Control for C++
Loading...
Searching...
No Matches
d:/Cpp/RoboidControl-cpp/Participant.h
1#pragma once
2#include "Thing.h"
3
4namespace RoboidControl {
5
6constexpr int MAX_THING_COUNT = 256;
7
10 public:
15 Participant* Get(const char* ipAddress, unsigned int port);
19 Participant* Get(unsigned char networkID);
20
25 Participant* Add(const char* ipAddress, unsigned int port);
28 void Add(Participant* participant);
29
32 void Remove(Participant* participant);
33
36 const std::list<Participant*>& GetAll() const;
37
38 private:
39#if defined(NO_STD)
40#else
42 std::list<Participant*> participants;
43#endif
44};
45
53 public:
55 const char* ipAddress = "0.0.0.0";
57 unsigned int port = 0;
58
60 unsigned char networkId = 0;
61
65 Participant(const char* ipAddress, int port);
68
69 public:
70#if defined(NO_STD)
71 unsigned char thingCount = 0;
72 Thing* things[MAX_THING_COUNT];
73#else
75 std::list<Thing*> things;
76#endif
80 Thing* Get(unsigned char thingId);
84 void Add(Thing* thing, bool checkId = true);
87 void Remove(Thing* thing);
88
91 virtual void Update(unsigned long currentTimeMs = 0);
92
93 public:
94 static ParticipantRegistry registry;
95};
96
97} // namespace RoboidControl
A participant is a device which manages things. It can communicate with other participant to synchron...
Definition Participant.h:52
void Add(Thing *thing, bool checkId=true)
Add a new thing for this participant.
Definition Participant.cpp:51
Thing * Get(unsigned char thingId)
Find a thing managed by this participant.
Definition Participant.cpp:40
unsigned char networkId
The network Id to identify the participant.
Definition Participant.h:60
unsigned int port
The port number for UDP communication with the participant.
Definition Participant.h:57
const char * ipAddress
The Ip Address of a participant.
Definition Participant.h:55
void Remove(Thing *thing)
Remove a thing for this participant.
Definition Participant.cpp:89
~Participant()
Destructor for the participant.
Definition Participant.cpp:28
std::list< Thing * > things
The things managed by this participant.
Definition Participant.h:75
virtual void Update(unsigned long currentTimeMs=0)
Update all things for this participant.
Definition Participant.cpp:33
class which manages all known participants
Definition Participant.h:9
const std::list< Participant * > & GetAll() const
Get all participants.
Definition Participant.cpp:175
Participant * Add(const char *ipAddress, unsigned int port)
Add a participant with the given details.
Definition Participant.cpp:142
Participant * Get(const char *ipAddress, unsigned int port)
Retrieve a participant by its address.
Definition Participant.cpp:114
void Remove(Participant *participant)
Remove a participant.
Definition Participant.cpp:171
A thing is the primitive building block.
Definition Thing.h:20