category.h

Go to the documentation of this file.
00001 /* -*- Mode: c++ -*- */
00002 /*
00003  *  this is part of Spm
00004  *
00005  *  Copyright (c) 2003-2006 Guillaume Chevallereau
00006  *
00007  *  This program is free software. You can redistribute it and/or modify it 
00008  *  under the terms of the GNU General Public License as published by the 
00009  *  Free Software Foundation. Either version 2 of the license or (at your 
00010  *  option) any later version.
00011  *
00012  *  This program is distributed in the hope that it will be usefull but WITHOUT
00013  *  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
00014  *  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for 
00015  *  more details.
00016  *
00017  *  You should have received a copy of the GNU General Public License along 
00018  *  with this program; if not, write to the Free Software Foundation, Inc., 
00019  *  59 Temple Place - Suite 330, Boston, MA  02111-1307, USA
00020  */
00021 #ifndef __CATEGORY_H__
00022 #define __CATEGORY_H__
00023 
00024 #include <string>
00025 #include <list>
00026 #include <fstream>
00027 #include "coreException.h"
00028 #include <util/object.h>
00029 
00030 namespace Spm
00031 {
00032   namespace Core
00033   {
00037     const std::string CATEGORY_NAME_ATTRIBUTE = "name";
00042     class Category : public Util::Object
00043     {
00044     public :
00045       friend class Store;
00046       typedef std::list<Category *>::iterator iterator;
00047       typedef std::list<Category *>::const_iterator const_iterator;
00048 
00049       typedef std::list<Category *>::reverse_iterator reverse_iterator;
00050       typedef std::list<Category *>::const_reverse_iterator const_reverse_iterator;
00051 
00052     private :
00053       friend class PackageSystem;
00054       std::string __owner;
00055       std::list<Category *> subCategorys;
00056       Category *topCategory;
00057 
00058     public :
00059       Category();
00063       Category (const std::string & categoryName)
00064         throw (BadNameException);
00065 
00066       ~Category ();
00067 
00071       void addSubCategory (Category * aSubCategory)
00072         throw (AlreadyExistingCategoryException);
00076       void delSubCategory (const std::string & aSubCategory)
00077         throw (UnknownCategoryException);
00082       const Category * getSubCategory (const std::string & aSubCategory)
00083         throw (UnknownCategoryException);
00084 
00088       const std::list<Category *> & getCategorys ();
00089 
00093       std::string getCompleteName ();
00094 
00098       std::string getCompleteName () const;
00099 
00103       void setName (const std::string & aName);
00104 
00108       void setTopCategory (const Category * category);
00109 
00113       const Category * getTopCategory ();
00114       const Category * getTopCategory () const;
00115       
00116       inline iterator begin ()
00117       {
00118         return subCategorys.begin ();
00119       }
00120 
00121       inline reverse_iterator rbegin ()
00122       {
00123         return subCategorys.rbegin ();
00124       }
00125 
00126       inline iterator end ()
00127       {
00128         return subCategorys.end ();
00129       }
00130 
00131       inline reverse_iterator rend ()
00132       {
00133         return subCategorys.rend ();
00134       }
00135 
00136       inline const_iterator begin () const
00137       {
00138         return subCategorys.begin ();
00139       }
00140 
00141       inline const_reverse_iterator rbegin () const
00142       {
00143         return subCategorys.rbegin ();
00144       }
00145 
00146       inline const_iterator end () const
00147       {
00148         return subCategorys.end ();
00149       }
00150 
00151       inline const_reverse_iterator rend () const
00152       {
00153         return subCategorys.rend ();
00154       }
00155 
00156       bool operator< (const Category * p) const;
00157       bool operator< (const Category & p) const;
00158 
00159       const std::string & getOwner ();
00160     };
00161 
00162     struct equalCategory : public std::binary_function<Category *, std::string, bool>
00163     {
00164       bool operator() (Category * category,
00165                        const std::string & categoryName) const;
00166     };
00167   }
00168 }
00169 #endif

Generated on Wed Jul 4 15:27:21 2007 for libSpm by  doxygen 1.4.6