1 // This file may be redistributed and modified only under the terms of 2 // the GNU Lesser General Public License (See COPYING for details). 3 // Copyright (C) 2000 Stefanus Du Toit 4 5 // $Id$ 6 7 #ifndef ATLAS_OBJECTS_ENCODER_H 8 #define ATLAS_OBJECTS_ENCODER_H 9 10 #include <Atlas/EncoderBase.h> 11 #include <Atlas/Objects/Root.h> 12 13 namespace Atlas { namespace Objects { 14 15 /** Objects hierarchy encoder 16 * 17 * This Encoder can be used to send objects in the Atlas::Objects hierarchy to 18 * a certain Bridge (e.g. a codec). 19 * 20 * Simply call the streamMessage member with a pointer to the object to be 21 * sent. 22 * 23 * @see Atlas::Objects::Decoder 24 * @author Stefanus Du Toit <sdt@gmx.net> 25 */ 26 class ObjectsEncoder : public Atlas::EncoderBase 27 { 28 public: 29 /// The default constructor. 30 /// @param b The Bridge to which objects are to be sent. ObjectsEncoder(Atlas::Bridge & b)31 explicit ObjectsEncoder(Atlas::Bridge & b) : EncoderBase(b) { } 32 /// The default destructor. 33 ~ObjectsEncoder(); 34 35 /// Send an object to the bridge. 36 /// @param o The object that is to be sent. 37 template <class ObjectData> streamObjectsMessage(const Atlas::Objects::SmartPtr<ObjectData> & o)38 void streamObjectsMessage(const Atlas::Objects::SmartPtr<ObjectData> & o) 39 { 40 m_b.streamMessage(); 41 o->sendContents(m_b); 42 m_b.mapEnd(); 43 } 44 }; 45 46 } } // namespace Atlas::Objects 47 48 #endif 49