8 #ifndef META_OCEAN_BASE_MAINTENANCE_H
9 #define META_OCEAN_BASE_MAINTENANCE_H
41 typedef std::vector<unsigned char>
Buffer;
68 static bool place(
const std::string& name,
const unsigned long long id,
const std::string& tag,
Buffer&& buffer,
const Timestamp timestamp);
80 static void encodeData(
const std::string& name,
const unsigned long long id,
const std::string& tag,
const Buffer& buffer,
const Timestamp timestamp,
const size_t reservedHeaderSize,
Buffer& encodedBuffer);
93 static bool decodeData(
const void* encodedBuffer,
const size_t encodedBufferSize, std::string& name,
unsigned long long&
id, std::string& tag,
Buffer& buffer,
Timestamp& timestamp);
130 inline Element(
const std::string& name,
const unsigned long long id,
const Timestamp timestamp,
const std::string& tag,
const Buffer& buffer);
140 inline Element(
const std::string& name,
const unsigned long long id,
const Timestamp timestamp,
const std::string& tag,
Buffer&& buffer);
146 inline const std::string& name()
const;
152 inline std::string& name();
158 inline unsigned long long id()
const;
170 inline const std::string& tag()
const;
176 inline std::string& tag();
182 inline const Buffer& buffer()
const;
235 inline bool isActive()
const;
242 inline std::string name()
const;
249 inline unsigned long long id()
const;
255 inline bool isEmpty()
const;
261 inline size_t size()
const;
269 inline void setActive(
const bool state);
277 inline void setName(
const std::string& name);
335 static inline void appendBuffer(
Buffer& firstBuffer,
const Buffer& secondBuffer);
355 bool place(
const std::string& name,
const unsigned long long id,
const std::string& tag,
Buffer&& buffer,
const Timestamp timestamp);
382 elementTimestamp(false)
388 elementName(element.elementName),
389 elementId(element.elementId),
390 elementTimestamp(element.elementTimestamp),
391 elementTag(element.elementTag),
392 elementBuffer(element.elementBuffer)
398 elementName(std::move(element.elementName)),
399 elementId(element.elementId),
400 elementTimestamp(element.elementTimestamp),
401 elementTag(std::move(element.elementTag)),
402 elementBuffer(std::move(element.elementBuffer))
404 element.elementId = 0ull;
405 element.elementTimestamp.toInvalid();
411 elementTimestamp(timestamp),
413 elementBuffer(buffer)
421 elementTimestamp(timestamp),
423 elementBuffer(std::move(buffer))
445 return elementTimestamp;
460 return elementBuffer;
465 return elementBuffer;
481 if (
this != &element)
483 elementName = std::move(element.elementName);
484 elementId = element.elementId;
485 elementTimestamp = element.elementTimestamp;
486 elementTag = std::move(element.elementTag);
487 elementBuffer = std::move(element.elementBuffer);
489 element.elementId = 0ull;
490 element.elementTimestamp.toInvalid();
548 Buffer result(firstBuffer.size() + secondBuffer.size());
549 memcpy(result.data(), firstBuffer.data(), firstBuffer.size());
550 memcpy(result.data() + firstBuffer.size(), secondBuffer.data(), secondBuffer.size());
557 const size_t firstBufferSize = firstBuffer.size();
559 firstBuffer.resize(firstBuffer.size() + secondBuffer.size());
560 memcpy(firstBuffer.data() + firstBufferSize, secondBuffer.data(), secondBuffer.size());
This class implements a recursive lock object.
Definition: Lock.h:31
This class is the base class for all maintenance connectors.
Definition: Maintenance.h:49
static void encodeData(const std::string &name, const unsigned long long id, const std::string &tag, const Buffer &buffer, const Timestamp timestamp, const size_t reservedHeaderSize, Buffer &encodedBuffer)
Encodes a maintenance data to one combined package.
static bool place(const std::string &name, const unsigned long long id, const std::string &tag, Buffer &&buffer, const Timestamp timestamp)
Explicitly places a maintenance data, information, message into the local maintenance manager.
static bool decodeData(const void *encodedBuffer, const size_t encodedBufferSize, std::string &name, unsigned long long &id, std::string &tag, Buffer &buffer, Timestamp ×tamp)
Decodes a package buffer to maintenance data with corresponding information.
Connector()
Creates a new connector.
Definition: Maintenance.h:375
This class implements a maintenance data element.
Definition: Maintenance.h:102
const std::string & tag() const
Returns the tag of the maintenance data of this element.
Definition: Maintenance.h:448
Buffer elementBuffer
The buffer of the data.
Definition: Maintenance.h:219
Element & operator=(const Element &element)
Assign operator.
Definition: Maintenance.h:468
std::string elementName
The name of the manager to which the data has been sent.
Definition: Maintenance.h:207
const Buffer & buffer() const
Returns the buffer of the maintenance data of this element.
Definition: Maintenance.h:458
unsigned long long elementId
The id of the manager to which the data has been sent.
Definition: Maintenance.h:210
Timestamp elementTimestamp
The timestamp of the data.
Definition: Maintenance.h:213
unsigned long long id() const
Return sthe id of the maintenance manager to which the maintenance data of this element has been sent...
Definition: Maintenance.h:438
const std::string & name() const
Returns the name of the maintenance manager to which the maintenance of this element data has been se...
Definition: Maintenance.h:428
Timestamp timestamp() const
The timestamp of the maintenance data of this element.
Definition: Maintenance.h:443
Element()
Creates a new empty element.
Definition: Maintenance.h:380
std::string elementTag
The tag of the data.
Definition: Maintenance.h:216
This class implements a maintenance manager.
Definition: Maintenance.h:33
Maintenance()
Creates a new maintenance manager object.
Definition: Maintenance.h:496
bool isActive() const
Returns whether the maintenance manager is active or not.
Definition: Maintenance.h:504
unsigned long long id() const
Returns a random id of this maintenance manager.
Definition: Maintenance.h:516
bool send(const std::string &tag, Buffer &&buffer, const Timestamp timestamp=Timestamp(true))
Sends new maintenance data to this manager.
unsigned long long maintenanceId
The random id of this manager.
Definition: Maintenance.h:366
std::queue< Element > ElementQueue
Definition of a vector holding maintenance data elements.
Definition: Maintenance.h:225
bool isEmpty() const
Returns whether this maintenance manager is currently empty (does not hold any maintenance data,...
Definition: Maintenance.h:522
std::string maintenanceName
The readable name of this manager.
Definition: Maintenance.h:363
bool maintenanceActive
The activation statement of this manager.
Definition: Maintenance.h:360
bool place(const std::string &name, const unsigned long long id, const std::string &tag, Buffer &&buffer, const Timestamp timestamp)
Explicitly places a maintenance data, information, message into this manager.
size_t size() const
Returns the number of maintenance data, information or messages which are currently stored in this ma...
Definition: Maintenance.h:528
static Buffer combine(const Buffer &firstBuffer, const Buffer &secondBuffer)
Combines two buffers.
Definition: Maintenance.h:546
std::vector< unsigned char > Buffer
Definition of a vector holding bytes.
Definition: Maintenance.h:41
void setName(const std::string &name)
Sets the name of this maintenance manager which should be a readable name of the application in which...
Definition: Maintenance.h:540
bool receive(std::string &name, unsigned long long &id, std::string &tag, Buffer &buffer, Timestamp ×tamp)
Receives the oldest maintenance data from this manager and pops it from the manager.
bool send(const std::string &tag, const Buffer &buffer, const Timestamp timestamp=Timestamp(true))
Sends new maintenance data to this manager.
static void appendBuffer(Buffer &firstBuffer, const Buffer &secondBuffer)
Appends a second buffer to a first buffer.
Definition: Maintenance.h:555
Lock maintenanceLock
The maintenance lock.
Definition: Maintenance.h:372
bool send(const std::string &tag, const void *data, const size_t size, const Timestamp timestamp=Timestamp(true))
Sends new maintenance data to this manager.
void setActive(const bool state)
Activates or deactivates this maintenance manager.
Definition: Maintenance.h:534
std::string name() const
Returns the name of this maintenance manager.
Definition: Maintenance.h:510
ElementQueue maintenanceElementQueue
The maintenance element queue.
Definition: Maintenance.h:369
This class provides base random functions and several random functions for integer data types.
Definition: RandomI.h:29
static uint64_t random64()
Returns one random integer number with range [0x00000000 00000000, 0xFFFFFFFF FFFFFFFF].
This class implements a scoped lock object for recursive lock objects.
Definition: Lock.h:135
This template class is the base class for all singleton objects.
Definition: Singleton.h:71
This class implements a timestamp.
Definition: Timestamp.h:36
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15