pion::platform::Codec Class Reference

#include <Codec.hpp>

Inherits pion::platform::PlatformPlugin.

Inherited by pion::plugins::JSONCodec, pion::plugins::LogCodec, and pion::plugins::XMLCodec.

List of all members.


Detailed Description

Codec: used to encode and decode Events using a particular format

Definition at line 41 of file Codec.hpp.

Public Member Functions

 Codec (void)
 constructs a new Codec object
virtual ~Codec ()
 virtual destructor: this class is meant to be extended
virtual const std::string & getContentType (void) const =0
 returns an HTTP content type that is used by this Codec
virtual boost::shared_ptr<
Codec
clone (void) const =0
virtual void write (std::ostream &out, const Event &e)=0
virtual void finish (std::ostream &out)=0
virtual bool read (std::istream &in, Event &e)=0
virtual void setConfig (const Vocabulary &v, const xmlNodePtr config_ptr)
virtual void updateVocabulary (const Vocabulary &v)
EventPtr read (std::istream &in, EventFactory &f)
Event::EventType getEventType (void) const
 returns the type of Event that is used by this Codec

Protected Member Functions

void copyCodec (const Codec &c)
 protected copy function (use clone() instead)

Classes

class  EmptyEventException
 exception thrown if the Codec configuration does not define an event type More...
class  NotAnObjectException
 exception thrown if the Codec configuration uses an event type for a Term that is not an object More...
class  UnknownTermException
 exception thrown if the Codec configuration references an unknown event type More...
class  WrongEventTypeException
 exception thrown if a Codec tries to read into an Event of a type different from what it's configured for More...


Member Function Documentation

virtual boost::shared_ptr<Codec> pion::platform::Codec::clone ( void   )  const [pure virtual]

clones the codec, returning a pointer to the cloned copy

Returns:
CodecPtr pointer to the cloned copy of the codec

Implemented in pion::plugins::JSONCodec, pion::plugins::LogCodec, and pion::plugins::XMLCodec.

Referenced by pion::platform::CodecFactory::getCodec().

virtual void pion::platform::Codec::finish ( std::ostream &  out  )  [pure virtual]

writes any needed footers (e.g. closing tag, JSON array end token, etc.) to an output stream and does any related cleanup

Parameters:
out the output stream to which the footers will be written

Implemented in pion::plugins::JSONCodec, pion::plugins::LogCodec, and pion::plugins::XMLCodec.

EventPtr pion::platform::Codec::read ( std::istream &  in,
EventFactory f 
) [inline]

reads an Event from an input stream

Parameters:
in the input stream to read the Event from
f the factory to use to create new Events
Returns:
EventPtr& pointer to the event read, if any; null if error

Definition at line 140 of file Codec.hpp.

References pion::platform::EventFactory::create().

virtual bool pion::platform::Codec::read ( std::istream &  in,
Event e 
) [pure virtual]

reads an Event from an input stream

Parameters:
in the input stream to read the Event from
e the Event read, if any; null if error
Returns:
true if successful, false otherwise

Implemented in pion::plugins::JSONCodec, pion::plugins::LogCodec, and pion::plugins::XMLCodec.

Referenced by PionPlatformUnitTest::feedFileToReactor().

void pion::platform::Codec::setConfig ( const Vocabulary v,
const xmlNodePtr  config_ptr 
) [virtual]

sets configuration parameters for this Codec

Parameters:
v the Vocabulary that this Codec will use to describe Terms
config_ptr pointer to a list of XML nodes containing Codec configuration parameters

Reimplemented from pion::platform::PlatformPlugin.

Reimplemented in pion::plugins::JSONCodec, pion::plugins::LogCodec, and pion::plugins::XMLCodec.

Definition at line 34 of file Codec.cpp.

References pion::platform::Vocabulary::findTerm(), pion::platform::ConfigManager::getConfigOption(), pion::platform::PlatformPlugin::getId(), pion::platform::PlatformPlugin::setConfig(), pion::platform::Vocabulary::Term::term_type, pion::platform::Vocabulary::TYPE_OBJECT, and pion::platform::Vocabulary::UNDEFINED_TERM_REF.

Referenced by pion::platform::CodecFactory::addPluginNoLock().

void pion::platform::Codec::updateVocabulary ( const Vocabulary v  )  [virtual]

this updates the Vocabulary information used by this Codec; it should be called whenever the global Vocabulary is updated

Parameters:
v the Vocabulary that this Codec will use to describe Terms

Reimplemented from pion::platform::PlatformPlugin.

Reimplemented in pion::plugins::JSONCodec, pion::plugins::LogCodec, and pion::plugins::XMLCodec.

Definition at line 55 of file Codec.cpp.

References pion::platform::PlatformPlugin::updateVocabulary().

virtual void pion::platform::Codec::write ( std::ostream &  out,
const Event e 
) [pure virtual]

writes an Event to an output stream

Parameters:
out the output stream to which the Event will be written
e the Event to write to the output stream

Implemented in pion::plugins::JSONCodec, pion::plugins::LogCodec, and pion::plugins::XMLCodec.


The documentation for this class was generated from the following files:
Generated on Wed Apr 13 16:38:35 2011 for pion-platform by  doxygen 1.4.7