Contains meta information about Encoders and Decoders. More...
#include <InstantIO/Codec.h>
Public Member Functions | |
Codec (const std::string &label, CreateEncoderMethod createEncoderMethod, CreateDecoderMethod createDecoderMethod, const std::string &author=std::string()) | |
Creates a new Codec object. | |
virtual | ~Codec () |
Destroys the Codec object. | |
virtual const char * | getTypeName () const |
Returns a human-readable string that describes the type that can be encoded and decoded by this Codec. | |
virtual bool | sameType (const BasicOutSlot &outSlot) const |
Checks if a the Codec has the same type as a given OutSlot. | |
virtual bool | sameType (const BasicInSlot &inSlot) const |
Checks if a the Codec has the same type as a given InSlot. |
Contains meta information about Encoders and Decoders.
Encoders and Decoders are used by the NetworkNode to transfer data values between InstantIO components on the network. Before any data type can be transferred via the network, Encoders and Decoders have to be written that transform data values to system and hardware independent byte streams and vice versa. For some frequently used data types, encoders and decoders already exist in the InstantIO package, but when you need to transfer your own data types, you have to implement encoders and decoders, and you have to create an instance of the Codec class that contains meta information about the encoders and decoders. This meta information consists of:
For example, let's say you want to transfer Integer
values via the network (a Codec for Integer
of course already exists in the InstantIO package, but for the sake of demonstrating the procedure whe nevertheless demonstrate how to create your own). First, you have to create classes that inherit from the Encoder and Decoder classes and implement the encoding and decoding of data values (see the documentation for these classes to get more information about how to do that). Then, you have to create an instance of the Codec class that specifies the meta information:
static Codec myIntCodec = new Codec( "Integer", Integer.class, MyIntEncoder.class, MyIntDecoder.class, "Patrick D&auml;hne");
InstantIO::Codec< T >::Codec | ( | const std::string & | label, | |
CreateEncoderMethod | createEncoderMethod, | |||
CreateDecoderMethod | createDecoderMethod, | |||
const std::string & | author = std::string() | |||
) | [inline] |
Creates a new Codec object.
label | The label of the Codec. This label is used to identify the Codec. Case does not matter. | |
createEncoderMethod | The method used to create new Encoders. | |
createDecoderMethod | The method used to create new Decoders. | |
author | The name of the person who wrote the codec. This information is not used by the InstantIO system in any way, it simply serves documentation purposes. |
virtual const char* InstantIO::Codec< T >::getTypeName | ( | ) | const [inline, virtual] |
Returns a human-readable string that describes the type that can be encoded and decoded by this Codec.
Implements InstantIO::BasicCodec.
virtual bool InstantIO::Codec< T >::sameType | ( | const BasicOutSlot & | outSlot | ) | const [inline, virtual] |
Checks if a the Codec has the same type as a given OutSlot.
outSlot | The OutSlot. |
Implements InstantIO::BasicCodec.
virtual bool InstantIO::Codec< T >::sameType | ( | const BasicInSlot & | inSlot | ) | const [inline, virtual] |
Checks if a the Codec has the same type as a given InSlot.
inSlot | The InSlot. |
Implements InstantIO::BasicCodec.