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-config.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 typedef runtime_error_custom<personality> error; 00049 00055 personality (); 00056 00062 personality (type persona); 00063 00069 personality (std::string const& persona); 00070 00072 ~personality (); 00073 00079 std::string const& get_name () const; 00080 00086 type 00087 get () const; 00088 00094 void 00095 set () const; 00096 00102 static void 00103 print_personalities (std::ostream& stream); 00104 00112 friend std::ostream& 00113 operator << (std::ostream& stream, 00114 personality const& rhs) 00115 { 00116 return stream << find_personality(rhs.persona); 00117 } 00118 00119 private: 00128 static type 00129 find_personality (std::string const& persona); 00130 00138 static std::string const& 00139 find_personality (type persona); 00140 00142 type persona; 00143 00145 static std::map<std::string,type> personalities; 00146 }; 00147 00148 } 00149 00150 #endif /* SBUILD_PERSONALITY_H */ 00151 00152 /* 00153 * Local Variables: 00154 * mode:C++ 00155 * End: 00156 */