Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   Related Pages  

property.hh

00001 /*
00002  * PIAVE - PIAVE Is A Video Editor
00003  *
00004  * Copyright (C) 2002 Rolf Dubitzky, rolf@dubitzky.de
00005  *
00006  */
00007 
00008 /*
00009  * This program is free software; you can redistribute it and/or modify
00010  * it under the terms of the GNU General Public License as published by
00011  * the Free Software Foundation; either version 2 of the License, or
00012  * (at your option) any later version.
00013  *
00014  * This program is distributed in the hope that it will be useful,
00015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  * GNU General Public License for more details.
00018  *
00019  * You should have received a copy of the GNU General Public License
00020  * along with this program; if not, write to the Free Software Foundation,
00021  * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00022  */
00023 
00024 
00029 #if ! defined( PROPERTY_HH )
00030 #define PROPERTY_HH
00031 
00032 // std++
00033 #include <iostream>
00034 #include <string>
00035 #include <vector>
00036 #include <map>
00037 
00038 
00039 namespace PIAVE {
00040 
00041     class PropertyNode;
00042     typedef std::vector< PropertyNode* > PropertyNodeList;
00043     typedef std::pair< std::string, std::string > Attribute;
00044     typedef std::map< std::string, std::string > AttrMap;
00045 
00046 
00047     class PropertyNode
00048     {
00049       public:
00050         PropertyNode( const std::string & n = std::string("") );
00051         PropertyNode( const PropertyNode & o );
00052         virtual ~PropertyNode();
00053 
00054         bool operator==( const PropertyNode & o ) const {
00055             return _name==o._name;
00056         }
00057         void operator=( const PropertyNode & o );
00058 
00059         /*   getter
00060          */
00061         std::string          getName()      const { return _name; }
00062         std::string          getContent()   const { return (*_content); }
00063         PropertyNode       * getDaughter( const std::string & n, int w=0, bool recurse = false );
00064         const PropertyNode * getDaughter( const std::string & n, int w=0, bool recurse = false ) const;
00065         PropertyNode       * getDaughter( unsigned int w=0 );
00066         const PropertyNode * getDaughter( unsigned int w=0 ) const;
00067         int                  getNDaughters() const { 
00068             return _daughters?_daughters->size():0;}
00069 
00070         bool getAttr( const std::string & a, std::string & v ) const;
00071         bool getAttr( const std::string & a, double & v ) const;
00072         bool getAttrRec( const std::string & a, std::string & v ) const;
00073         bool getAttrRec( const std::string & a, double & v ) const;
00074 
00075         /*   setter
00076          */
00077         void setName( const std::string & c );
00078         void setContent( const std::string & c );
00079         void addAttr( const std::string & n, const std::string & v );
00080         void addAttr( const std::string & n, const double & v );
00081         void addAttr( const std::string & n, const int & v );
00082         PropertyNode* addDaughter( const std::string & n );
00083         void addDaughter( PropertyNode* );
00084 
00085         void toXML( std::ostream & o, int indent = 2 ) const ;
00086         std::string toXML() const ;
00087 
00088         bool provides( PropertyNode * caps, bool recurse = true ) const;
00089 
00090       private:
00091         std::string         _name;
00092         std::string       * _content;
00093         AttrMap           * _attrMap;
00094         PropertyNodeList  * _daughters;
00095     };
00096 
00097 }
00098 
00099 
00100 #endif

Generated on Tue Oct 14 20:45:37 2003 for piave by doxygen1.2.18