Login | Register
My pages Projects Community openCollabNet

Container.hpp

Go to the documentation of this file.
00001 #ifndef CONTAINER_CLASS_H
00002 #define CONTAINER_CLASS_H 1
00003 
00008 /*
00009    libprf1 - Preferences Registry Format configuration file access
00010    library
00011 
00012    Copyright (C) 2003,2004 Andrei Sosnin
00013 
00014    This program is free software; you can redistribute it and/or modify
00015    it under the terms of the GNU General Public License as published by
00016    the Free Software Foundation; either version 2, or (at your option)
00017    any later version.
00018 
00019    This program is distributed in the hope that it will be useful,
00020    but WITHOUT ANY WARRANTY; without even the implied warranty of
00021    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00022    GNU General Public License for more details.
00023 
00024    You should have received a copy of the GNU General Public License
00025    along with this program; if not, write to the Free Software Foundation,
00026    Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  
00027 
00028 */
00029 
00030 #include <map>
00031 #include "ContainerItem.hpp"
00032 
00033 #ifdef CXX_NAMESPACES
00034 XERCES_CPP_NAMESPACE_USE
00035 namespace prf{
00036 #endif
00037 
00045   class Container {
00046     
00047   public:
00048 
00049     typedef ContainerItem element_type;
00050     
00051     typedef element_type::value_type value_type;
00052     typedef const element_type::value_type const_value_type;
00053     
00054     typedef value_type key_type;
00055     typedef unsigned int hash_type;
00056 
00057     typedef element_type::repr_type repr_type;
00058 
00059     typedef size_t size_type;
00060     
00061     typedef std::map<const hash_type, element_type*> container_type;
00062 
00063     typedef container_type::iterator iterator;
00064         
00065     virtual ~Container() throw();
00066     
00068     static const value_type child_name;
00069     
00075     virtual void deleteItem(const key_type idkey);
00076     virtual void deleteItem(const char *idkey);
00077 
00083     virtual element_type *getItem(const key_type key);
00084     virtual element_type *getItem(const char* key);
00085 
00093     virtual void setItem(const key_type idkey, element_type *value);
00094     virtual void setItem(const char* idkey, element_type *value);
00095 
00100     virtual iterator addItem(element_type* _elem);
00101 
00105     virtual void addItems(container_type& _elems);
00106     
00107 
00113     virtual iterator createItem(key_type idkey) = 0;
00114     
00118     virtual size_type size() const;
00119 
00123     virtual repr_type *getNode();
00124     
00125     // ---------------------------------------------------------------
00126     // Language-dependent methods
00127 
00132     virtual element_type &operator[] (const key_type key);
00137     virtual element_type &operator[] (const char* key); 
00138     
00139     // ---------------------------------------------------------------
00140     // FUTURE:
00145     virtual iterator begin();
00146     
00151     virtual iterator end();
00152     
00153 
00154   protected:
00155     // Deny using default & copy constructors and assignment operator
00156     Container(){}
00157     Container(Container &){}
00158     Container &operator=(Container){}
00159     
00160     inline void deleteItem(const hash_type hash);
00161     inline element_type *getItem(const hash_type hash);
00162     inline void setItem(const hash_type hash, element_type *value);
00163 
00168     container_type *elem;
00169     
00174     repr_type *xelem;
00175     
00176   };
00177   
00178 #ifdef CXX_NAMESPACES
00179 }
00180 #endif
00181 
00182 #endif 

Generated on Tue May 11 05:03:49 2004 for libprf1 by doxygen 1.3.6-20040222