EvolvingObjects
Object.h
00001 /*
00002 (c) Thales group, 2012
00003 
00004     This library is free software; you can redistribute it and/or
00005     modify it under the terms of the GNU Lesser General Public
00006     License as published by the Free Software Foundation;
00007     version 2 of the License.
00008 
00009     This library is distributed in the hope that it will be useful,
00010     but WITHOUT ANY WARRANTY; without even the implied warranty of
00011     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012     Lesser General Public License for more details.
00013 
00014     You should have received a copy of the GNU Lesser General Public
00015     License along with this library; if not, write to the Free Software
00016     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00017 Contact: http://eodev.sourceforge.net
00018 
00019 Authors:
00020     Benjamin Bouvier <benjamin.bouvier@gmail.com>
00021 */
00022 # ifndef __EOSERIAL_OBJECT_H__
00023 # define __EOSERIAL_OBJECT_H__
00024 
00025 # include <map>
00026 # include <string>
00027 
00028 # include "Entity.h"
00029 # include "Serializable.h"
00030 
00031 namespace eoserial
00032 {
00041     class Object : public eoserial::Entity, public std::map< std::string, eoserial::Entity* >
00042     {
00043         public:
00044             typedef std::map<std::string, eoserial::Entity*> JsonValues;
00045 
00051             void add( const std::string& key, eoserial::Entity* json )
00052             {
00053                 (*this)[ key ] = json;
00054             }
00055 
00061             void add( const std::string& key, const eoserial::Printable* obj )
00062             {
00063                 (*this)[ key ] = obj->pack();
00064             }
00065 
00070             void deserialize( eoserial::Persistent & obj )
00071             {
00072                 obj.unpack( this );
00073             }
00074 
00078             ~Object();
00079 
00083             virtual std::ostream& print( std::ostream& out ) const;
00084     };
00085 
00086 } // namespace eoserial
00087 # endif // __EOSERIAL_OBJECT_H__
00088 
 All Classes Namespaces Files Functions Variables Typedefs Friends