branch.h

Go to the documentation of this file.
00001 /* -*- Mode: c++ -*- */
00002 /*
00003  *  this is part of Spm
00004  *
00005  *  Copyright (c) 2005-2008 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 __BRANCH_H__ 
00022 #define __BRANCH_H__
00023 #include <map>
00024 #include <list>
00025 #include "coreException.h"
00026 #include <util/utilException.h>
00027 #include <plugin/installerInterface.h>
00028 #include <algorithm>
00029 #include <boost/filesystem/path.hpp>
00030 #include "versionned.h"
00031 
00032 namespace Spm
00033 {
00034   namespace Core
00035   {
00040     class Branch : public Versionned
00041     {
00042       friend class PackageSystem;
00043       friend class Element;
00044       friend class ElementStore;
00045       std::vector<Versionned *> elements_;
00046     public:
00047       typedef std::vector<Versionned *>::iterator iterator;
00048       typedef std::vector<Versionned *>::const_iterator const_iterator;
00049       typedef std::vector<Versionned *>::reverse_iterator reverse_iterator;
00050       typedef std::vector<Versionned *>::const_reverse_iterator const_reverse_iterator;
00051       static miniXml::ustring getBranchName (const miniXml::ustring major,
00052                                              const miniXml::ustring minor);
00053       Branch () : Versionned()
00054       { 
00055       }
00056 
00060       Branch (Element * aElement);
00061 
00067       Branch (const miniXml::ustring & aMajor, 
00068               const miniXml::ustring & aMinor, 
00069               Element * aElement);
00070 
00071       ~Branch ();
00072 
00073       void add (Versionned * v);
00074       Versionned * remove (const miniXml::ustring & name);
00075       void remove (Versionned * v);
00076       bool have (Versionned * v);
00077       bool have (Versionned * v) const;
00078       
00079       const std::vector<Versionned *> & versions ()
00080       {
00081         return elements_;
00082       }
00083 
00084       const std::vector<Versionned *> & versions () const
00085       {
00086         return elements_;
00087       }
00088 
00089       iterator begin ()
00090       {
00091         return elements_.begin ();
00092       }
00093 
00094       iterator end ()
00095       {
00096         return elements_.end ();
00097       }
00098 
00099       const_iterator begin () const
00100       {
00101         return elements_.begin ();
00102       }
00103 
00104       const_iterator end () const
00105       {
00106         return elements_.end ();
00107       }
00108 
00109       reverse_iterator rbegin ()
00110       {
00111         return elements_.rbegin ();
00112       }
00113 
00114       reverse_iterator rend ()
00115       {
00116         return elements_.rend ();
00117       }
00118 
00119       const_reverse_iterator rbegin () const
00120       {
00121         return elements_.rbegin ();
00122       }
00123 
00124       const_reverse_iterator rend () const
00125       {
00126         return elements_.rend ();
00127       }
00128 
00129       bool operator< (const Branch & b) const;
00130 
00131       bool operator< (const miniXml::ustring & branchVersion);
00132       bool operator== (const miniXml::ustring & branchVersion);
00133       bool operator== (const Branch & otherBranch) const;
00134     };
00135   }
00136 }
00137 #endif

Generated on Sat Mar 21 17:00:14 2009 for libSpm by  doxygen 1.5.2