24 #include <interface/interface_info.h> 25 #include <interface/interface.h> 26 #include <utils/misc/strndup.h> 27 #include <utils/time/time.h> 53 unsigned int serial,
bool has_writer,
unsigned int num_readers,
54 const std::list<std::string> &readers,
const std::string &writer,
55 const Time *timestamp)
57 __type = strndup(type, __INTERFACE_TYPE_SIZE);
58 __id = strndup(
id, __INTERFACE_ID_SIZE);
59 __hash = (
unsigned char *)malloc(__INTERFACE_HASH_SIZE);
60 memcpy(__hash, hash, __INTERFACE_HASH_SIZE);
64 __timestamp =
new Time(timestamp);
75 __type = strndup(i.__type, __INTERFACE_TYPE_SIZE);
76 __id = strndup(i.__id, __INTERFACE_ID_SIZE);
77 __hash = (
unsigned char *)malloc(__INTERFACE_HASH_SIZE);
78 memcpy(__hash, i.__hash, __INTERFACE_HASH_SIZE);
79 __has_writer = i.__has_writer;
80 __num_readers = i.__num_readers;
81 __serial = i.__serial;
82 __timestamp =
new Time(i.__timestamp);
83 __readers = i.__readers;
84 __writer = i.__writer;
121 const unsigned char *
133 char phash[__INTERFACE_HASH_SIZE * 2 + 1];
134 phash[__INTERFACE_HASH_SIZE * 2] = 0;
135 for (
size_t s = 0; s < __INTERFACE_HASH_SIZE; ++s) {
136 snprintf(&phash[s*2], 3,
"%02X", __hash[s]);
138 return std::string(phash);
158 return __num_readers;
165 const std::list<std::string> &
212 int td = strncmp(__type, ii.__type, __INTERFACE_TYPE_SIZE);
218 return (strncmp(__id, ii.__id, __INTERFACE_ID_SIZE) < 0);
243 const std::list<std::string> &
readers,
const std::string &
writer,
246 push_back(
InterfaceInfo(type,
id, hash, serial, has_writer, num_readers, readers, writer, ×tamp));
const char * type() const
Get interface type.
Fawkes library namespace.
const char * id() const
Get interface ID.
bool operator<(const InterfaceInfo &ii) const
< operator This compares two interface infos with respect to the less than (<) relation considering t...
A class for handling time.
const unsigned char * hash() const
Get interface version hash.
const Time * timestamp() const
Get interface timestamp.
InterfaceInfo(const char *type, const char *id, const unsigned char *hash, unsigned int serial, bool has_writer, unsigned int num_readers, const std::list< std::string > &readers, const std::string &writer, const Time *timestamp)
Constructor.
const std::string & writer() const
Get name of writer on interface.
const std::list< std::string > & readers() const
Get readers of interface.
bool has_writer() const
Check if there is a writer.
unsigned int serial() const
Get interface instance serial.
~InterfaceInfo()
Destructor.
unsigned int num_readers() const
Get number of readers.
void append(const char *type, const char *id, const unsigned char *hash, unsigned int serial, bool has_writer, unsigned int num_readers, const std::list< std::string > &readers, const std::string &writer, const Time ×tamp)
Append an interface info.
std::string hash_printable() const
Get interface version hash in printable format.