Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members

PHObjectVector.h

Go to the documentation of this file.
00001 #ifndef __PHOBJECTVECTOR_H__
00002 #define __PHOBJECTVECTOR_H__
00003 
00004 #include "PHObject.h"
00005 
00009 template<class BASE>
00010 class PHObjectVector : public PHObject
00011 {
00012  public:
00013 
00014   typedef BASE* value_type;
00015   typedef const value_type& const_reference;
00016   typedef value_type& reference;
00017   typedef unsigned int size_type;
00018 
00019   virtual ~PHObjectVector() {}
00020 
00022   virtual value_type add(const size_type& index) = 0;
00023   
00025   virtual value_type add(const size_type& index, const value_type& value) = 0;
00026 
00028   virtual value_type back() const
00029   {
00030     if (!empty())
00031       {
00032         return get(size()-1);
00033       }
00034     else
00035       {
00036         return value_type();
00037       }
00038   }
00039 
00041   virtual size_type capacity() const = 0;
00042 
00044   virtual PHObjectVector<BASE>* clone() const = 0;
00045 
00047   virtual PHObjectVector<BASE>* create() const = 0;
00048 
00050   virtual bool empty() const { return size()==0; }
00051 
00053   virtual void erase(const size_type& i) = 0;
00054 
00056   virtual value_type front() const { return get(0); }
00057 
00059   virtual value_type get(const size_type& index) const = 0;
00060  
00062   virtual void identify(std::ostream& os = std::cout) const = 0;
00063 
00065   virtual int isValid() const = 0;
00066 
00068   virtual void pop_back()
00069   {
00070     if (!empty())
00071       {
00072         erase(size()-1);
00073       }
00074   }
00075 
00077   virtual void push_back(const value_type& val)
00078   {
00079     add(size(),val);
00080   }
00081 
00083   virtual void Reset() = 0;
00084 
00086   virtual bool reserve(const size_type& n) = 0;
00087 
00091   virtual bool resize(const size_type& newsize, value_type v = value_type()) = 0;
00092 
00094   virtual size_type size() const = 0;
00095 
00096  private:
00097   ClassDefT(PHObjectVector,0)
00098 };
00099 
00100 ClassDefT2(PHObjectVector,BASE)
00101 ClassImpT(PHObjectVector,BASE)
00102 
00103 #endif