ShInfo.hpp

00001 // Sh: A GPU metaprogramming language.
00002 //
00003 // Copyright 2003-2005 Serious Hack Inc.
00004 // 
00005 // This library is free software; you can redistribute it and/or
00006 // modify it under the terms of the GNU Lesser General Public
00007 // License as published by the Free Software Foundation; either
00008 // version 2.1 of the License, or (at your option) any later version.
00009 //
00010 // This library is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013 // Lesser General Public License for more details.
00014 //
00015 // You should have received a copy of the GNU Lesser General Public
00016 // License along with this library; if not, write to the Free Software
00017 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
00018 // MA  02110-1301, USA
00020 #ifndef SHINFO_HPP
00021 #define SHINFO_HPP
00022 
00023 #include <list>
00024 #include <string>
00025 #include "ShDllExport.hpp"
00026 
00027 namespace SH {
00028 
00032 class 
00033 SH_DLLEXPORT
00034 ShInfo {
00035 public:
00036   virtual ~ShInfo();
00037   virtual ShInfo* clone() const = 0;
00038   
00039 protected:
00040   ShInfo();
00041 };
00042 
00044 class
00045 SH_DLLEXPORT
00046 ShInfoComment: public ShInfo {
00047 public:
00048   ShInfoComment(const std::string& comment); 
00049   ShInfo* clone() const;
00050 
00051   std::string comment; 
00052 };
00053 
00059 class
00060 SH_DLLEXPORT ShInfoHolder {
00061 public:
00062 
00063   ShInfoHolder();
00064 
00065   // Clones the info list from other 
00066   ShInfoHolder(const ShInfoHolder &other);
00067 
00068   // Makes this list equal to a clone of other's list
00069   ShInfoHolder& operator=(const ShInfoHolder &other);
00070 
00071   ~ShInfoHolder();
00072 
00073   // Return the first entry in info whose type matches T, or 0 if no
00074   // such entry exists.
00075   // @{
00076   template<typename T>
00077   T* get_info();
00078   template<typename T>
00079   const T* get_info() const;
00080   // @}
00081 
00082   // Delete and remove all info entries matching the given type.
00083   template<typename T>
00084   void destroy_info();
00085 
00086   // Add the given statement information to the end of the info list.
00087   void add_info(ShInfo* new_info);
00088 
00089   // Remove the given statement information from the list.
00090   // Does not delete it, so be careful!
00091   void remove_info(ShInfo* old_info);
00092 
00093 private:
00094   void erase_all();
00095 
00096   typedef std::list<ShInfo*> InfoList;
00097   InfoList info;
00098 
00099 };
00100 
00101 } // namespace SH
00102 
00103 #include "ShInfoImpl.hpp"
00104 
00105 #endif

Generated on Wed Nov 9 15:29:32 2005 for Sh by  doxygen 1.4.5