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

ShInfoImpl.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 SHINFOIMPL_HPP
00021 #define SHINFOIMPL_HPP
00022 
00023 #include "ShInfo.hpp"
00024 
00025 namespace SH {
00026 
00027 template<typename T>
00028 T* ShInfoHolder::get_info()
00029 {
00030   for (InfoList::iterator I = info.begin(); I != info.end(); ++I) {
00031     T* item = dynamic_cast<T*>(*I);
00032     if (item) {
00033       return item;
00034     }
00035   }
00036   return 0;
00037 }
00038 
00039 template<typename T>
00040 const T* ShInfoHolder::get_info() const
00041 {
00042   for (InfoList::const_iterator I = info.begin(); I != info.end(); ++I) {
00043     const T* item = dynamic_cast<const T*>(*I);
00044     if (item) {
00045       return item;
00046     }
00047   }
00048   return 0;
00049 }
00050 
00051 template<typename T>
00052 void ShInfoHolder::destroy_info()
00053 {
00054   for (InfoList::iterator I = info.begin(); I != info.end();) {
00055     T* item = dynamic_cast<T*>(*I);
00056     if (item) {
00057       I = info.erase(I);
00058       delete item;
00059     } else {
00060       ++I;
00061     }
00062   }
00063 }
00064 
00065 } // namespace SH
00066 
00067 #endif

Generated on Thu Jul 28 17:33:02 2005 for Sh by  doxygen 1.4.3-20050530