sbuild-chroot-config.h

Go to the documentation of this file.
00001 /* Copyright © 2005-2006  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         CHROOT,      
00057         DIR_OPEN,    
00058         FILE_NOTREG, 
00059         FILE_OPEN,   
00060         FILE_OWNER,  
00061         FILE_PERMS,  
00062         FILE_STAT    
00063       };
00064 
00066     typedef custom_error<error_code> error;
00067 
00069     typedef std::tr1::shared_ptr<chroot_config> ptr;
00070 
00072     chroot_config ();
00073 
00082     chroot_config (std::string const& file,
00083                    bool               active);
00084 
00086     virtual ~chroot_config ();
00087 
00097     void
00098     add (std::string const& location,
00099          bool               active);
00100 
00101   private:
00110     void
00111     add_config_file (std::string const& file,
00112                      bool               active);
00113 
00122     void
00123     add_config_directory (std::string const& dir,
00124                           bool               active);
00125 
00126   protected:
00136     void
00137     add (chroot::ptr& chroot);
00138 
00139   public:
00146     chroot_list
00147     get_chroots () const;
00148 
00155     const chroot::ptr
00156     find_chroot (std::string const& name) const;
00157 
00164     const chroot::ptr
00165     find_alias (std::string const& name) const;
00166 
00174     string_list
00175     get_chroot_list () const;
00176 
00182     void
00183     print_chroot_list (std::ostream& stream) const;
00184 
00191     void
00192     print_chroot_list_simple (std::ostream& stream) const;
00193 
00201     void
00202     print_chroot_info (string_list const& chroots,
00203                        std::ostream&      stream) const;
00204 
00212     void
00213     print_chroot_location (string_list const& chroots,
00214                            std::ostream&      stream) const;
00215 
00223     void
00224     print_chroot_config (string_list const& chroots,
00225                          std::ostream&      stream) const;
00226 
00234     string_list
00235     validate_chroots (string_list const& chroots) const;
00236 
00237   private:
00247     void
00248     load_data (std::string const& file,
00249                bool               active);
00250 
00259     virtual void
00260     parse_data (std::istream& stream,
00261                 bool          active);
00262 
00264     chroot_map chroots;
00266     string_map aliases;
00267   };
00268 
00269 }
00270 
00271 #endif /* SBUILD_CHROOT_CONFIG_H */
00272 
00273 /*
00274  * Local Variables:
00275  * mode:C++
00276  * End:
00277  */

Generated on Fri Jul 14 19:52:16 2006 for schroot by  doxygen 1.4.7