00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef __ELEMENT_H__
00022 #define __ELEMENT_H__
00023
00024 #include <string>
00025 #include <list>
00026 #include <map>
00027 #include <fstream>
00028 #include "branch.h"
00029 #include "category.h"
00030 #include "coreException.h"
00031 #include <plugin/installerInterface.h>
00032 #include <util/object.h>
00033
00034 #include <functional>
00035 #include <algorithm>
00036
00037
00038 namespace Spm
00039 {
00040 namespace Core
00041 {
00045 const std::string ELEMENT_ATTRIBUTE_NAME = "name";
00046 const std::string ELEMENT_NODE_DESCRIPTION = "description";
00047 const std::string ELEMENT_NODE_BRANCHES = "branches";
00048 const std::string ELEMENT_NODE_BRANCH = "branch";
00049 const std::string ELEMENT_ATTRIBUTE_ELEMENT = "element";
00050 const std::string ELEMENT_ATTRIBUTE_VERSION = "version";
00051 const std::string ELEMENT_NODE_CATEGORY = "category";
00056 class Element : public Util::Object
00057 {
00058 friend class Store;
00059 public :
00060 typedef std::list<Branch *>::iterator iterator;
00061 typedef std::list<Branch *>::const_iterator const_iterator;
00062 typedef std::list<Branch *>::reverse_iterator reverse_iterator;
00063 typedef std::list<Branch *>::const_reverse_iterator const_reverse_iterator;
00064 protected:
00065 Category * category;
00066 std::string description;
00067 std::string elementURL;
00068 std::list<Branch *> branches;
00069 Element ();
00070
00071 public:
00072 virtual ~Element ();
00073
00077 const std::string & getDescription ();
00078
00082 const std::string & getDescription () const;
00083
00087 void setName (const std::string & name);
00088
00092 void setDescription (const std::string & description);
00093
00097 const Category * getCategory ();
00098
00102 const Category * getCategory () const;
00103
00107 void setCategory (Category * aCategory);
00108
00112 void addBranch (Branch * aBranch)
00113 throw (AlreadyExistingBranchException);
00114
00118 void removeBranch (const std::string & aBranch)
00119 throw (UnknownBranchException, NoRightException);
00120
00124 std::list<Branch *> & getBranches ();
00125 const std::list<Branch *> & getBranches () const;
00126
00131 std::list<Branch *> getUserBranches (const std::string & user);
00132
00136 std::list<Branch *> getSystemBranches ();
00137
00142 const Branch * getBranch (const std::string & branchName)
00143 throw (UnknownBranchException);
00144
00149 Branch * getRefBranch (const std::string & branchName)
00150 throw (UnknownBranchException);
00151
00157 virtual bool uninstall (const std::string & branchName = "")
00158 throw (UnknownBranchException);
00159
00165 virtual Branch * queryForFile (const std::string & file)
00166 throw (FileNotFoundException);
00167
00168 std::list<Branch *> findSameBranch (const std::string & branchName)
00169 throw (UnknownBranchException);
00170
00171 bool operator< (const Element * e) const;
00172 bool operator< (const Element & e) const;
00173
00174 iterator begin ()
00175 {
00176 return branches.begin ();
00177 }
00178
00179 iterator end ()
00180 {
00181 return branches.end ();
00182 }
00183
00184 const_iterator begin () const
00185 {
00186 return branches.begin ();
00187 }
00188
00189 const_iterator end () const
00190 {
00191 return branches.end ();
00192 }
00193
00194 reverse_iterator rbegin ()
00195 {
00196 return branches.rbegin ();
00197 }
00198
00199 reverse_iterator rend ()
00200 {
00201 return branches.rend ();
00202 }
00203
00204 const_reverse_iterator rbegin () const
00205 {
00206 return branches.rbegin ();
00207 }
00208
00209 const_reverse_iterator rend () const
00210 {
00211 return branches.rend ();
00212 }
00213 };
00214
00215 struct equalElement : public std::binary_function<Element *, std::string, bool>
00216 {
00217 bool operator() (Element * element,
00218 const std::string & elementName) const;
00219 };
00220
00221 struct equalBranchByBranch : public std::binary_function<Branch *, Branch *, bool>
00222 {
00223 bool operator()(const Branch * branch, const Branch * branchToSearch) const;
00224 };
00225
00229 struct equalBranch : public std::binary_function<Branch *, std::string, bool>
00230 {
00231 bool operator()(const Branch * branch, const std::string & branchName) const;
00232 };
00233
00234 struct branchContainFile : public std::binary_function<Branch *, std::string, bool>
00235 {
00236 bool operator() (Branch * branch,
00237 const std::string & file) const;
00238 };
00239
00240 struct equalBranchMajorMinor : public std::binary_function<Branch *, std::string, bool>
00241 {
00242 bool operator() (Branch * branch,
00243 const std::string & file) const;
00244 };
00248 }
00249 }
00250 #endif