00001 /* 00002 * Copyright (C) 2004 Andrew Sutton 00003 * 00004 * This library is free software; you can redistribute it and/or 00005 * modify it under the terms of the GNU Lesser General Public 00006 * License as published by the Free Software Foundation; either 00007 * version 2.1 of the License, or (at your option) any later version. 00008 * 00009 * This library is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 * Lesser General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU Lesser General Public 00015 * License along with this library; if not, write to: 00016 * 00017 * The Free Software Foundation, Inc. 00018 * 59 Temple Place, Suite 330 00019 * Boston, MA 02111-1307 USA 00020 * 00021 * Contact: 00022 * Andrew Sutton asutton@cs.kent.edu 00023 */ 00024 00025 #ifndef OMF_EXTENSION_HPP 00026 #define OMF_EXTENSION_HPP 00027 00028 // std includes 00029 #include <string> 00030 00031 namespace OMF 00032 { 00037 struct Extension 00038 { 00039 Extension(const std::string &name) : 00040 _name(name) 00041 {} 00042 00043 virtual ~Extension() 00044 {} 00045 00046 const std::string &name() const 00047 { return _name; } 00048 00049 protected: 00050 std::string _name; 00051 }; 00052 00073 template <class Type> 00074 class BasicExtension : public Extension 00075 { 00076 public: 00077 BasicExtension(const std::string &name) : 00078 Extension(name), 00079 _value() 00080 {} 00081 00082 BasicExtension(const std::string &name, Type &value) : 00083 Extension(name), 00084 _value(value) 00085 {} 00086 00087 virtual ~BasicExtension() 00088 {} 00089 00090 Type &get() 00091 { return _value; } 00092 00093 void set(Type &value) 00094 { return _value; } 00095 00096 protected: 00097 Type _value; 00098 }; 00099 } 00100 00101 #endif