sbuild-chroot-config.h

Go to the documentation of this file.
00001 /* Copyright © 2005-2007  Roger Leigh <rleigh@debian.org>
00002  *
00003  * schroot is free software: you can redistribute it and/or modify it
00004  * under the terms of the GNU General Public License as published by
00005  * the Free Software Foundation, either version 3 of the License, or
00006  * (at your option) any later version.
00007  *
00008  * schroot is distributed in the hope that it will be useful, but
00009  * WITHOUT ANY WARRANTY; without even the implied warranty of
00010  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011  * General Public License for more details.
00012  *
00013  * You should have received a copy of the GNU General Public License
00014  * along with this program.  If not, see
00015  * <http://www.gnu.org/licenses/>.
00016  *
00017  *********************************************************************/
00018 
00019 #ifndef SBUILD_CHROOT_CONFIG_H
00020 #define SBUILD_CHROOT_CONFIG_H
00021 
00022 #include <sbuild/sbuild-chroot.h>
00023 #include <sbuild/sbuild-custom-error.h>
00024 
00025 #include <map>
00026 #include <ostream>
00027 #include <vector>
00028 #include <string>
00029 
00030 namespace sbuild
00031 {
00032 
00042  class chroot_config
00043   {
00044   public:
00046     typedef std::vector<chroot::ptr> chroot_list;
00048     typedef std::map<std::string, std::string> string_map;
00050     typedef std::map<std::string, chroot::ptr> chroot_map;
00051 
00053     enum error_code
00054       {
00055         ALIAS_EXIST,     
00056         CHROOT_NOTFOUND, 
00057         CHROOT_EXIST,    
00058         FILE_NOTREG,     
00059         FILE_OPEN,       
00060         FILE_OWNER,      
00061         FILE_PERMS       
00062       };
00063 
00065     typedef custom_error<error_code> error;
00066 
00068     typedef std::tr1::shared_ptr<chroot_config> ptr;
00069 
00071     chroot_config ();
00072 
00081     chroot_config (std::string const& file,
00082                    bool               active);
00083 
00085     virtual ~chroot_config ();
00086 
00096     void
00097     add (std::string const& location,
00098          bool               active);
00099 
00100   private:
00109     void
00110     add_config_file (std::string const& file,
00111                      bool               active);
00112 
00121     void
00122     add_config_directory (std::string const& dir,
00123                           bool               active);
00124 
00125   protected:
00136     void
00137     add (chroot::ptr&   chroot,
00138          keyfile const& kconfig);
00139 
00140   public:
00147     chroot_list
00148     get_chroots () const;
00149 
00156     const chroot::ptr
00157     find_chroot (std::string const& name) const;
00158 
00165     const chroot::ptr
00166     find_alias (std::string const& name) const;
00167 
00175     string_list
00176     get_chroot_list () const;
00177 
00183     void
00184     print_chroot_list (std::ostream& stream) const;
00185 
00192     void
00193     print_chroot_list_simple (std::ostream& stream) const;
00194 
00202     void
00203     print_chroot_info (string_list const& chroots,
00204                        std::ostream&      stream) const;
00205 
00213     void
00214     print_chroot_location (string_list const& chroots,
00215                            std::ostream&      stream) const;
00216 
00224     void
00225     print_chroot_config (string_list const& chroots,
00226                          std::ostream&      stream) const;
00227 
00235     string_list
00236     validate_chroots (string_list const& chroots) const;
00237 
00238   private:
00248     void
00249     load_data (std::string const& file,
00250                bool               active);
00251 
00252   protected:
00261     virtual void
00262     parse_data (std::istream& stream,
00263                 bool          active);
00264 
00273     virtual void
00274     load_keyfile (keyfile& kconfig,
00275                   bool     active);
00276 
00278     chroot_map chroots;
00280     string_map aliases;
00281   };
00282 
00283 }
00284 
00285 #endif /* SBUILD_CHROOT_CONFIG_H */
00286 
00287 /*
00288  * Local Variables:
00289  * mode:C++
00290  * End:
00291  */

Generated on Mon May 5 09:25:41 2008 for sbuild by  doxygen 1.5.5