8#ifndef META_OCEAN_BASE_MAINTENANCE_H
9#define META_OCEAN_BASE_MAINTENANCE_H
68 static bool place(
const std::string& name,
const uint64_t
id,
const std::string& tag,
Buffer&& buffer,
const Timestamp timestamp);
97 static void encodeData(
const std::string& name,
const uint64_t
id,
const std::string& tag,
const Buffer& buffer,
const Timestamp timestamp,
const size_t reservedHeaderSize,
Buffer& encodedBuffer);
110 static bool decodeData(
const void* encodedBuffer,
const size_t encodedBufferSize, std::string& name, uint64_t&
id, std::string& tag,
Buffer& buffer,
Timestamp& timestamp);
147 inline Element(
const std::string& name,
const uint64_t
id,
const Timestamp timestamp,
const std::string& tag,
const Buffer& buffer);
157 inline Element(
const std::string& name,
const uint64_t
id,
const Timestamp timestamp,
const std::string& tag,
Buffer&& buffer);
163 inline const std::string& name()
const;
169 inline std::string& name();
175 inline uint64_t id()
const;
187 inline const std::string& tag()
const;
193 inline std::string& tag();
199 inline const Buffer& buffer()
const;
252 inline bool isActive()
const;
259 inline std::string name()
const;
266 inline uint64_t id()
const;
272 inline bool isEmpty()
const;
278 inline size_t size()
const;
286 inline void setActive(
const bool state);
294 inline void setName(
const std::string& name);
352 static inline void appendBuffer(
Buffer& firstBuffer,
const Buffer& secondBuffer);
372 bool place(
const std::string& name,
const uint64_t
id,
const std::string& tag,
Buffer&& buffer,
const Timestamp timestamp);
400 timestamp_(timestamp),
410 timestamp_(timestamp),
412 buffer_(std::move(buffer))
511 Buffer result(firstBuffer.size() + secondBuffer.size());
512 memcpy(result.data(), firstBuffer.data(), firstBuffer.size());
513 memcpy(result.data() + firstBuffer.size(), secondBuffer.data(), secondBuffer.size());
520 const size_t firstBufferSize = firstBuffer.size();
522 firstBuffer.resize(firstBuffer.size() + secondBuffer.size());
523 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 bool decodeData(const void *encodedBuffer, const size_t encodedBufferSize, std::string &name, uint64_t &id, std::string &tag, Buffer &buffer, Timestamp ×tamp)
Decodes a package buffer to maintenance data with corresponding information.
static void encodeData(const std::string &name, const uint64_t 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 uint64_t id, const std::string &tag, Buffer &&buffer, const Timestamp timestamp)
Explicitly places a maintenance data, information, message into the local maintenance manager.
Connector()
Creates a new connector.
Definition Maintenance.h:392
This class implements a maintenance data element.
Definition Maintenance.h:119
const std::string & tag() const
Returns the tag of the maintenance data of this element.
Definition Maintenance.h:437
std::string tag_
The tag of the data.
Definition Maintenance.h:233
uint64_t id() const
Return sthe id of the maintenance manager to which the maintenance data of this element has been sent...
Definition Maintenance.h:427
std::string name_
The name of the manager to which the data has been sent.
Definition Maintenance.h:224
Element(Element &&element)=default
Move constructor.
Element()=default
Creates a new empty element.
const Buffer & buffer() const
Returns the buffer of the maintenance data of this element.
Definition Maintenance.h:447
Buffer buffer_
The buffer of the data.
Definition Maintenance.h:236
Element & operator=(const Element &element)=default
Assign operator.
Element(const Element &element)=default
Copy constructor.
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:417
Element & operator=(Element &&element)=default
Assign operator.
Timestamp timestamp() const
The timestamp of the maintenance data of this element.
Definition Maintenance.h:432
This class implements a maintenance manager.
Definition Maintenance.h:33
uint64_t maintenanceId
The random id of this manager.
Definition Maintenance.h:383
bool place(const std::string &name, const uint64_t id, const std::string &tag, Buffer &&buffer, const Timestamp timestamp)
Explicitly places a maintenance data, information, message into this manager.
Maintenance()
Creates a new maintenance manager object.
Definition Maintenance.h:457
bool isActive() const
Returns whether the maintenance manager is active or not.
Definition Maintenance.h:467
bool receive(std::string &name, uint64_t &id, std::string &tag, Buffer &buffer, Timestamp ×tamp)
Receives the oldest maintenance data from this manager and pops it from the manager.
std::queue< Element > ElementQueue
Definition of a vector holding maintenance data elements.
Definition Maintenance.h:242
bool send(const std::string &tag, Buffer &&buffer, const Timestamp timestamp=Timestamp(true))
Sends new maintenance data to this manager.
std::vector< uint8_t > Buffer
Definition of a vector holding bytes.
Definition Maintenance.h:41
bool isEmpty() const
Returns whether this maintenance manager is currently empty (does not hold any maintenance data,...
Definition Maintenance.h:485
std::string maintenanceName
The readable name of this manager.
Definition Maintenance.h:380
bool maintenanceActive
The activation statement of this manager.
Definition Maintenance.h:377
size_t size() const
Returns the number of maintenance data, information or messages which are currently stored in this ma...
Definition Maintenance.h:491
static Buffer combine(const Buffer &firstBuffer, const Buffer &secondBuffer)
Combines two buffers.
Definition Maintenance.h:509
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:503
uint64_t id() const
Returns a random id of this maintenance manager.
Definition Maintenance.h:479
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:518
Lock maintenanceLock
The maintenance lock.
Definition Maintenance.h:389
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:497
std::string name() const
Returns the name of this maintenance manager.
Definition Maintenance.h:473
ElementQueue maintenanceElementQueue
The maintenance element queue.
Definition Maintenance.h:386
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:147
This template class is the base class for all singleton objects.
Definition Singleton.h:71
This class implements a timestamp.
Definition Timestamp.h:64
The namespace covering the entire Ocean framework.
Definition Accessor.h:15