Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

ShInfo.hpp

00001 // Sh: A GPU metaprogramming language.
00002 //
00003 // Copyright 2003-2005 Serious Hack Inc.
00004 // 
00005 // This software is provided 'as-is', without any express or implied
00006 // warranty. In no event will the authors be held liable for any damages
00007 // arising from the use of this software.
00008 // 
00009 // Permission is granted to anyone to use this software for any purpose,
00010 // including commercial applications, and to alter it and redistribute it
00011 // freely, subject to the following restrictions:
00012 // 
00013 // 1. The origin of this software must not be misrepresented; you must
00014 // not claim that you wrote the original software. If you use this
00015 // software in a product, an acknowledgment in the product documentation
00016 // would be appreciated but is not required.
00017 // 
00018 // 2. Altered source versions must be plainly marked as such, and must
00019 // not be misrepresented as being the original software.
00020 // 
00021 // 3. This notice may not be removed or altered from any source
00022 // distribution.
00024 #ifndef SHINFO_HPP
00025 #define SHINFO_HPP
00026 
00027 #include <list>
00028 #include <string>
00029 #include "ShDllExport.hpp"
00030 
00031 namespace SH {
00032 
00036 class 
00037 SH_DLLEXPORT
00038 ShInfo {
00039 public:
00040   virtual ~ShInfo();
00041   virtual ShInfo* clone() const = 0;
00042   
00043 protected:
00044   ShInfo();
00045 };
00046 
00048 class
00049 SH_DLLEXPORT
00050 ShInfoComment: public ShInfo {
00051 public:
00052   ShInfoComment(const std::string& comment); 
00053   ShInfo* clone() const;
00054 
00055   std::string comment; 
00056 };
00057 
00063 class
00064 SH_DLLEXPORT ShInfoHolder {
00065 public:
00066 
00067   ShInfoHolder();
00068 
00069   // Clones the info list from other 
00070   ShInfoHolder(const ShInfoHolder &other);
00071 
00072   // Makes this list equal to a clone of other's list
00073   ShInfoHolder& operator=(const ShInfoHolder &other);
00074 
00075   ~ShInfoHolder();
00076 
00077   // Return the first entry in info whose type matches T, or 0 if no
00078   // such entry exists.
00079   // @{
00080   template<typename T>
00081   T* get_info();
00082   template<typename T>
00083   const T* get_info() const;
00084   // @}
00085 
00086   // Delete and remove all info entries matching the given type.
00087   template<typename T>
00088   void destroy_info();
00089 
00090   // Add the given statement information to the end of the info list.
00091   void add_info(ShInfo* new_info);
00092 
00093   // Remove the given statement information from the list.
00094   // Does not delete it, so be careful!
00095   void remove_info(ShInfo* old_info);
00096 
00097 private:
00098   void erase_all();
00099 
00100   typedef std::list<ShInfo*> InfoList;
00101   InfoList info;
00102 
00103 };
00104 
00105 } // namespace SH
00106 
00107 #include "ShInfoImpl.hpp"
00108 
00109 #endif

Generated on Thu Apr 21 17:32:47 2005 for Sh by  doxygen 1.4.2