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

ShMetaImpl.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 SH_METAIMPL_HPP
00025 #define SH_METAIMPL_HPP
00026 
00027 #include "ShMeta.hpp"
00028 
00029 namespace SH {
00030 
00031 inline ShMeta::ShMeta(const ShMeta &other)
00032   : m_meta(0)
00033 {
00034   if(other.m_meta) {
00035     m_meta = new MetaMap();
00036     *m_meta = *other.m_meta;
00037   }
00038 }
00039 
00040 inline ShMeta::~ShMeta()
00041 {
00042   if(m_meta) delete m_meta;
00043 }
00044 
00045 inline std::string ShMeta::name() const
00046 {
00047   return meta("n"); 
00048 }
00049 
00050 inline void ShMeta::name(const std::string& n)
00051 {
00052   meta("n", n);
00053 }
00054 
00055 inline bool ShMeta::has_name() const
00056 {
00057   return !meta("n").empty(); 
00058 }
00059 
00060 inline bool ShMeta::internal() const
00061 {
00062   return !meta("i").empty(); 
00063 }
00064 
00065 inline void ShMeta::internal(bool i)
00066 {
00067   meta("i", i ? "1" : "");
00068 }
00069 
00070 inline std::string ShMeta::title() const
00071 {
00072   return meta("t");
00073 }
00074 
00075 inline void ShMeta::title(const std::string& t)
00076 {
00077   meta("t", t);
00078 }
00079 
00080 inline std::string ShMeta::description() const
00081 {
00082   return meta("d");
00083 }
00084 
00085 inline void ShMeta::description(const std::string& d)
00086 {
00087   meta("d", d);
00088 }
00089 
00090 inline std::string ShMeta::meta(const std::string& key) const
00091 {
00092   if(!m_meta) return std::string(); 
00093 
00094   MetaMap::const_iterator I = m_meta->find(key);
00095   if (I == m_meta->end()) return std::string();
00096   return I->second;
00097 }
00098 
00099 inline void ShMeta::meta(const std::string& key, const std::string& value)
00100 {
00101   if(!m_meta) m_meta = new MetaMap();
00102   (*m_meta)[key] = value;
00103 }
00104 
00105 inline bool ShMeta::has_meta(const std::string& key) const
00106 {
00107   return m_meta && (m_meta->find(key) != m_meta->end());
00108 }
00109 
00110 }
00111 
00112 #endif
00113 

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