Repository.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *
00003  * Copyright (C) 2009-2010 Cassio Neri Moreira
00004  *
00005  * This file is part of the KeyValue library.
00006  *
00007  * The KeyValue library is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License as published
00009  * by the Free Software Foundation, either version 3 of the License, or (at
00010  * your option) any later version.
00011  *
00012  * The KeyValue library is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
00015  * Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License along
00018  * with KeyValue. If not, see <http://www.gnu.org/licenses/>.
00019  *
00020  **************************************************************************/
00021 
00028 #ifndef KEYVALUE_MNGT_REPOSITORY_H_
00029 #define KEYVALUE_MNGT_REPOSITORY_H_
00030 
00031 #include <map>
00032 
00033 #include <boost/utility.hpp>
00034 
00035 #include "keyvalue/extern/SharedPtr.h"
00036 #include "keyvalue/sys/exception/Exception.h"
00037 #include "keyvalue/value/Vector.h"
00038 
00039 namespace keyvalue {
00040 
00041 // Forward declarations
00042 
00043 class DataSet;
00044 
00053 class Repository : private boost::noncopyable {
00054 
00055 public:
00056 
00062   static Repository&
00063   getInstance();
00064 
00080   void
00081   add(shared_ptr<DataSet> dataSet);
00082 
00091   bool
00092   erase(const string& name);
00093 
00099   size_t
00100   clear();
00101 
00110   shared_ptr<DataSet>
00111   find(const string& name) const;
00112 
00122   shared_ptr<DataSet>
00123   getDataSet(const string& name) const;
00124 
00130   size_t
00131   getSize() const;
00132 
00139   value::Vector
00140   getList() const;
00141 
00145   class NotFound : public RuntimeError {
00146 
00147   public:
00148 
00149     /***
00150      * @brief   Constructor stores the name of DataSet which was not found.
00151      *
00152      * @param   name  : Name of DataSet which was not found.
00153      */
00154     explicit
00155     NotFound(string name);
00156 
00157     ~NotFound() throw();
00158 
00159     /***
00160      * @brief   Gets the name of DataSet which was not found.
00161      *
00162      * @return  The name od DataSet which was not found.
00163      */
00164     const string&
00165     getName() const;
00166 
00167   private:
00168 
00169     const string name_;
00170   };
00171 
00172 private:
00173 
00174   typedef std::map <string, shared_ptr<DataSet> > Map_;
00175   typedef Map_::value_type                        Pair_;
00176   Map_                                            map_;
00177 
00178   Repository();
00179 
00180 }; // class Repository
00181 
00182 } // namespace keyvalue
00183 
00184 #endif // KEYVALUE_MNGT_REPOSITORY_H_

Generated on Sat Mar 20 15:08:29 2010 for KeyValue by  doxygen 1.6.1