PCMContainer_impl.h

Go to the documentation of this file.
00001 
00002 //
00003 // This source file is a part of ParCompMark
00004 // Parallel Compositing Benchmark Framework
00005 //
00006 // for latest info see http://parcompmark.sourceforge.net
00007 
00008 //
00009 // Copyright (C) 2006 IT2 ParCompMark Dev. Team
00010 // 
00011 // This program is free software; you can redistribute it and/or
00012 // modify it under the terms of the GNU General Public License
00013 // as published by the Free Software Foundation; either version 2
00014 // of the License, or (at your option) any later version.
00015 // 
00016 // This program is distributed in the hope that it will be useful,
00017 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00018 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00019 // GNU General Public License for more details.
00020 // 
00021 // You should have received a copy of the GNU General Public License
00022 // along with this program; if not, write to the Free Software
00023 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00024 
00027 
00028  //
00029  // Constructors & destructor
00030  //
00031 
00032 template < class ElementType, class LockType > inline Container < ElementType, LockType >::Container()
00033   // You have to initialize the following attributes:
00034   // - mElements
00035 {
00036   // STL auto-initialization
00037 }
00038 
00039  /*----------------------------------------------------------------------*/
00040 
00041 template < class ElementType, class LockType > inline Container < ElementType, LockType >::~Container()
00042 {
00043   // STL auto-finalization
00044 }
00045 
00046  /*----------------------------------------------------------------------*/
00047 
00048  //
00049  // Methods
00050  //
00051 
00052 template < class ElementType, class LockType > void Container < ElementType,
00053  LockType >::add(std::string name, ElementPointer element)
00054 {
00055   Assert(!has(name), INVALID_NAME_ERROR, "Container::add");
00056   mElements[name] = element;
00057 }
00058 
00059  /*----------------------------------------------------------------------*/
00060 
00061 template < class ElementType, class LockType > typename ElementType::Pointer Container < ElementType,
00062   LockType >::get(const std::string & name)
00063 {
00064   Assert(has(name), INVALID_NAME_ERROR, "Container::get");
00065   return mElements[name];
00066 }
00067 
00068  /*----------------------------------------------------------------------*/
00069 
00070 template < class ElementType, class LockType > bool Container < ElementType,
00071   LockType >::has(const std::string & name)
00072 {
00073   return mElements.find(name) != mElements.end();
00074 }
00075 
00076  /*----------------------------------------------------------------------*/
00077 
00078 template < class ElementType, class LockType > void Container < ElementType,
00079 LockType >::remove(const std::string & name)
00080 {
00081   Assert(has(name), INVALID_NAME_ERROR, "Container::remove");
00082   mElements.erase(name);
00083 }
00084 
00085  /*----------------------------------------------------------------------*/
00086 
00087 template < class ElementType, class LockType > u32 Container < ElementType, LockType >::getSize()
00088 {
00089   return mElements.size();
00090 }
00091 
00092  /*----------------------------------------------------------------------*/
00093 
00094 template < class ElementType, class LockType > bool Container < ElementType, LockType >::isEmpty()
00095 {
00096   return !getSize();
00097 }
00098 
00099  /*----------------------------------------------------------------------*/
00100 
00101 template < class ElementType, class LockType > typename std::map < std::string,
00102   typename ElementType::Pointer >::iterator Container < ElementType, LockType >::begin()
00103 {
00104   return mElements.begin();
00105 }
00106 
00107  /*----------------------------------------------------------------------*/
00108 
00109 template < class ElementType, class LockType > typename std::map < std::string,
00110   typename ElementType::Pointer >::iterator Container < ElementType, LockType >::end()
00111 {
00112   return mElements.end();
00113 }
00114 
00115  /*----------------------------------------------------------------------*/