X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=senf%2FPackets%2FMainpage.dox;h=9323740e47f1a13bd42f4a27892cf6f4ddf3ad32;hb=3a0e403d889f8a16d78d50bbcd7a0f0157b05313;hp=308d9ac404c9f28f29e1e90c5dcc2b24546180b5;hpb=601d1f509f5bb24df167a4dd5a20da67a0af9af8;p=senf.git diff --git a/senf/Packets/Mainpage.dox b/senf/Packets/Mainpage.dox index 308d9ac..9323740 100644 --- a/senf/Packets/Mainpage.dox +++ b/senf/Packets/Mainpage.dox @@ -676,6 +676,10 @@ struct Timestamp { senf::ClockService::clock_t value; }; + + std::ostream & operator<<(std::ostream & os, Timestamp const & tstamp) { + os << tstamp.value; return os; + } senf::EthernetPacket packet (senf::EthernetPacket::create(senf::noinit)); sock.read(packet.data(), 0u); @@ -687,17 +691,20 @@ \code if (senf::ClockService::now() - packet.annotation().value > senf::ClockService::seconds(1)) { - // Ouch ... this packet is to old + // this packet is to old // ... } \endcode - + It is very important to define a specific structure (or class or enum) type for each type of annotation. \e Never directly store a fundamental type as an annotation: The name of the type is used to look up the annotation, so you can store only one annotation for each built-in type. \c typedef does not help since \c typedef does not introduce new type names, it only defines an alias. + The annotation type must support the output \c operator<< for description purposes + (e.g. for the \ref senf::Packet::dump() "Packet::dump()" member). + Of course, the annotation structure can be arbitrary. However, one very important caveat: If the annotation is not a POD type, it needs to inherit from senf::ComplexAnnotation. A type is POD, if it is really just a bunch of bytes: No (non-static) members, no constructor or destructor and