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 2 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, write to the Free Software
00015  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
00016  * MA  02111-1307  USA
00017  *
00018  *********************************************************************/
00019 
00020 #ifndef SBUILD_CHROOT_CONFIG_H
00021 #define SBUILD_CHROOT_CONFIG_H
00022 
00023 #include <sbuild/sbuild-chroot.h>
00024 #include <sbuild/sbuild-custom-error.h>
00025 
00026 #include <map>
00027 #include <ostream>
00028 #include <vector>
00029 #include <string>
00030 
00031 namespace sbuild
00032 {
00033 
00043  class chroot_config
00044   {
00045   public:
00047     typedef std::vector<chroot::ptr> chroot_list;
00049     typedef std::map<std::string, std::string> string_map;
00051     typedef std::map<std::string, chroot::ptr> chroot_map;
00052 
00054     enum error_code
00055       {
00056         ALIAS_EXIST,     
00057         CHROOT_NOTFOUND, 
00058         CHROOT_EXIST,    
00059         FILE_NOTREG,     
00060         FILE_OPEN,       
00061         FILE_OWNER,      
00062         FILE_PERMS,      
00063         FILE_STAT        
00064       };
00065 
00067     typedef custom_error<error_code> error;
00068 
00070     typedef std::tr1::shared_ptr<chroot_config> ptr;
00071 
00073     chroot_config ();
00074 
00083     chroot_config (std::string const& file,
00084                    bool               active);
00085 
00087     virtual ~chroot_config ();
00088 
00098     void
00099     add (std::string const& location,
00100          bool               active);
00101 
00102   private:
00111     void
00112     add_config_file (std::string const& file,
00113                      bool               active);
00114 
00123     void
00124     add_config_directory (std::string const& dir,
00125                           bool               active);
00126 
00127   protected:
00138     void
00139     add (chroot::ptr&   chroot,
00140          keyfile const& kconfig);
00141 
00142   public:
00149     chroot_list
00150     get_chroots () const;
00151 
00158     const chroot::ptr
00159     find_chroot (std::string const& name) const;
00160 
00167     const chroot::ptr
00168     find_alias (std::string const& name) const;
00169 
00177     string_list
00178     get_chroot_list () const;
00179 
00185     void
00186     print_chroot_list (std::ostream& stream) const;
00187 
00194     void
00195     print_chroot_list_simple (std::ostream& stream) const;
00196 
00204     void
00205     print_chroot_info (string_list const& chroots,
00206                        std::ostream&      stream) const;
00207 
00215     void
00216     print_chroot_location (string_list const& chroots,
00217                            std::ostream&      stream) const;
00218 
00226     void
00227     print_chroot_config (string_list const& chroots,
00228                          std::ostream&      stream) const;
00229 
00237     string_list
00238     validate_chroots (string_list const& chroots) const;
00239 
00240   private:
00250     void
00251     load_data (std::string const& file,
00252                bool               active);
00253 
00254   protected:
00263     virtual void
00264     parse_data (std::istream& stream,
00265                 bool          active);
00266 
00275     virtual void
00276     load_keyfile (keyfile& kconfig,
00277                   bool     active);
00278 
00280     chroot_map chroots;
00282     string_map aliases;
00283   };
00284 
00285 }
00286 
00287 #endif /* SBUILD_CHROOT_CONFIG_H */
00288 
00289 /*
00290  * Local Variables:
00291  * mode:C++
00292  * End:
00293  */

Generated on Sun Jul 8 21:23:22 2007 for sbuild by  doxygen 1.5.2