00001 /* Copyright © 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_PERSONALITY_H 00021 #define SBUILD_PERSONALITY_H 00022 00023 #include <sbuild/sbuild-custom-error.h> 00024 00025 #include <map> 00026 #include <ostream> 00027 #include <string> 00028 00029 namespace sbuild 00030 { 00031 00041 class personality 00042 { 00043 public: 00045 typedef unsigned long type; 00046 00048 enum error_code 00049 { 00050 SET 00051 }; 00052 00054 typedef custom_error<error_code> error; 00055 00061 personality (); 00062 00068 personality (type persona); 00069 00075 personality (std::string const& persona); 00076 00078 ~personality (); 00079 00085 std::string const& get_name () const; 00086 00092 type 00093 get () const; 00094 00100 void 00101 set () const; 00102 00108 static void 00109 print_personalities (std::ostream& stream); 00110 00118 friend std::ostream& 00119 operator << (std::ostream& stream, 00120 personality const& rhs) 00121 { 00122 return stream << find_personality(rhs.persona); 00123 } 00124 00125 private: 00134 static type 00135 find_personality (std::string const& persona); 00136 00144 static std::string const& 00145 find_personality (type persona); 00146 00148 type persona; 00149 00151 static std::map<std::string,type> personalities; 00152 }; 00153 00154 } 00155 00156 #endif /* SBUILD_PERSONALITY_H */ 00157 00158 /* 00159 * Local Variables: 00160 * mode:C++ 00161 * End: 00162 */