InstantIO::Codec< T > Class Template Reference

Contains meta information about Encoders and Decoders. More...

#include <InstantIO/Codec.h>

Inheritance diagram for InstantIO::Codec< T >:
InstantIO::BasicCodec

List of all members.

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.

Detailed Description

template<class T>
class InstantIO::Codec< T >

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&amp;auml;hne");
 

Author:
Patrick Dähne
See also:
NetworkNode NetworkNode
Encoder Encoder
Decoder Decoder

Constructor & Destructor Documentation

template<class T >
InstantIO::Codec< T >::Codec ( const std::string &  label,
CreateEncoderMethod  createEncoderMethod,
CreateDecoderMethod  createDecoderMethod,
const std::string &  author = std::string() 
) [inline]

Creates a new Codec object.

Parameters:
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.

Member Function Documentation

template<class T >
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.

Returns:
A string that describes the type that can be encoded or decoded by this Codec.

Implements InstantIO::BasicCodec.

template<class T >
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.

Parameters:
outSlot The OutSlot.
Returns:
true when the Codec and the OutSlot have the same type, false otherwise.

Implements InstantIO::BasicCodec.

template<class T >
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.

Parameters:
inSlot The InSlot.
Returns:
true when the Codec and the InSlot have the same type, false otherwise.

Implements InstantIO::BasicCodec.


The documentation for this class was generated from the following file:
Generated on Thu Jul 31 17:17:32 2014 by  doxygen 1.6.3