CrystalSpace

Public API Reference

csutil/scfarray.h

Go to the documentation of this file.
00001 /*
00002     Copyright (C) 2006 by Frank Richter
00003 
00004     This library is free software; you can redistribute it and/or
00005     modify it under the terms of the GNU Library General Public
00006     License as published by the Free Software Foundation; either
00007     version 2 of the License, or (at your option) any later version.
00008 
00009     This library is distributed in the hope that it will be useful,
00010     but WITHOUT ANY WARRANTY; without even the implied warranty of
00011     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012     Library General Public License for more details.
00013 
00014     You should have received a copy of the GNU Library General Public
00015     License along with this library; if not, write to the Free
00016     Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00017 */
00018 
00019 #ifndef __CS_CSUTIL_SCFARRAY_H__
00020 #define __CS_CSUTIL_SCFARRAY_H__
00021 
00027 #include "iutil/array.h"
00028 
00029 #include "csutil/array.h"
00030 #include "csutil/scf_implementation.h"
00031 
00032 #include "csutil/win32/msvc_deprecated_warn_off.h"
00033 
00056 template<typename IF, 
00057   typename Backend = csArray<typename IF::ContainedType> >
00058 class scfArray : 
00059   public scfImplementation1<scfArray<IF, Backend>, IF>
00060 {
00061   typedef scfImplementation1<scfArray<IF, Backend>, IF> scfImplementationType;
00062   typedef typename IF::ContainedType ContainedType;
00063 public:
00065   Backend storage;
00066 
00068 
00069   scfArray () : scfImplementationType (this) {}
00070   scfArray (iBase* scfParent) : scfImplementationType (this, scfParent) {}
00072 
00073 
00074   scfArray (const Backend& storage) : scfImplementationType (this), 
00075     storage (storage) {}
00076   scfArray (const Backend& storage, iBase* scfParent) : 
00077     scfImplementationType (this, scfParent), storage (storage) {}
00079 
00082   virtual size_t GetSize () const
00083   { return storage.GetSize(); }
00084   virtual ContainedType const& Get (size_t n) const
00085   { return storage.Get (n); }
00086   virtual ContainedType const& Top () const
00087   { return storage.Top(); }
00088   virtual size_t Find (ContainedType const& which) const
00089   { return storage.Find (which); }
00090   virtual size_t GetIndex (const ContainedType* which) const
00091   { return storage.GetIndex (which); }
00092   virtual bool IsEmpty() const
00093   { return storage.IsEmpty(); }
00094   virtual void GetAll (ContainedType* dest) const
00095   {
00096     for (size_t i = 0; i < storage.GetSize(); i++)
00097       dest[i] = storage[i];
00098   }
00103   virtual ContainedType& Get (size_t n)
00104   { return storage.Get (n); }
00105   virtual ContainedType& Top ()
00106   { return storage.Top(); }
00111   virtual void SetSize (size_t n, ContainedType const& what)
00112   { storage.SetSize (n, what); }
00113   virtual void SetSize (size_t n)
00114   { storage.SetSize (n); }
00115   virtual ContainedType& GetExtend (size_t n)
00116   { return storage.GetExtend (n); }
00117   virtual void Put (size_t n, ContainedType const& what)
00118   { storage.Put (n, what); }
00119   virtual size_t Push (ContainedType const& what)
00120   { return storage.Push (what); }
00121   virtual size_t PushSmart (ContainedType const& what)
00122   { return storage.PushSmart (what); }
00123   virtual ContainedType Pop ()
00124   { return storage.Pop (); }
00125   virtual bool Insert (size_t n, ContainedType const& item)
00126   { return storage.Insert (n, item); }
00127   virtual void DeleteAll ()
00128   { storage.DeleteAll(); }
00129   virtual void Truncate (size_t n)
00130   { storage.Truncate(n); }
00131   virtual void Empty ()
00132   { storage.Empty(); }
00133   virtual bool DeleteIndex (size_t n)
00134   { return storage.DeleteIndex  (n); }
00135   virtual bool DeleteIndexFast (size_t n)
00136   { return storage.DeleteIndexFast  (n); }
00137   virtual bool Delete (ContainedType const& item)
00138   { return storage.Delete (item); }
00139   virtual bool DeleteFast (ContainedType const& item)
00140   { return storage.DeleteFast (item); }
00142 };
00143 
00153 template<typename IF, typename Backend>
00154 class scfArrayWrap : 
00155   public scfImplementation1<scfArrayWrap<IF, Backend>, IF>
00156 {
00157   typedef scfImplementation1<scfArrayWrap<IF, Backend>, IF> 
00158     scfImplementationType;
00159   typedef typename IF::ContainedType ContainedType;
00160 public:
00162   Backend& storage;
00163 
00165 
00166   scfArrayWrap (Backend& storage) : scfImplementationType (this), 
00167     storage (storage) {}
00168   scfArrayWrap (Backend& storage, iBase* scfParent) : 
00169     scfImplementationType (this, scfParent), storage (storage) {}
00171 
00174   virtual size_t GetSize () const
00175   { return storage.GetSize(); }
00176   virtual ContainedType const& Get (size_t n) const
00177   { return storage.Get (n); }
00178   virtual ContainedType const& Top () const
00179   { return storage.Top(); }
00180   virtual size_t Find (ContainedType const& which) const
00181   { return storage.Find (which); }
00182   virtual size_t GetIndex (const ContainedType* which) const
00183   { return storage.GetIndex (which); }
00184   virtual bool IsEmpty() const
00185   { return storage.IsEmpty(); }
00186   virtual void GetAll (ContainedType* dest) const
00187   {
00188     for (size_t i = 0; i < storage.GetSize(); i++)
00189       dest[i] = storage[i];
00190   }
00195   virtual ContainedType& Get (size_t n)
00196   { return storage.Get (n); }
00197   virtual ContainedType& Top ()
00198   { return storage.Top(); }
00203   virtual void SetSize (size_t n, ContainedType const& what)
00204   { storage.SetSize (n, what); }
00205   virtual void SetSize (size_t n)
00206   { storage.SetSize (n); }
00207   virtual ContainedType& GetExtend (size_t n)
00208   { return storage.GetExtend (n); }
00209   virtual void Put (size_t n, ContainedType const& what)
00210   { storage.Put (n, what); }
00211   virtual size_t Push (ContainedType const& what)
00212   { return storage.Push (what); }
00213   virtual size_t PushSmart (ContainedType const& what)
00214   { return storage.PushSmart (what); }
00215   virtual ContainedType Pop ()
00216   { return storage.Pop (); }
00217   virtual bool Insert (size_t n, ContainedType const& item)
00218   { return storage.Insert (n, item); }
00219   virtual void DeleteAll ()
00220   { storage.DeleteAll(); }
00221   virtual void Truncate (size_t n)
00222   { storage.Truncate(n); }
00223   virtual void Empty ()
00224   { storage.Empty(); }
00225   virtual bool DeleteIndex (size_t n)
00226   { return storage.DeleteIndex  (n); }
00227   virtual bool DeleteIndexFast (size_t n)
00228   { return storage.DeleteIndexFast  (n); }
00229   virtual bool Delete (ContainedType const& item)
00230   { return storage.Delete (item); }
00231   virtual bool DeleteFast (ContainedType const& item)
00232   { return storage.DeleteFast (item); }
00234 };
00235 
00244 template<typename IF, typename Backend>
00245 class scfArrayWrapConst : 
00246   public scfImplementation1<scfArrayWrapConst<IF, Backend>, IF>
00247 {
00248   typedef scfImplementation1<scfArrayWrapConst<IF, Backend>, IF> 
00249     scfImplementationType;
00250   typedef typename IF::ContainedType ContainedType;
00251 public:
00253   const Backend& storage;
00254 
00256 
00257   scfArrayWrapConst (const Backend& storage) : scfImplementationType (this), 
00258     storage (storage) {}
00259   scfArrayWrapConst (const Backend& storage, iBase* scfParent) : 
00260     scfImplementationType (this, scfParent), storage (storage) {}
00262 
00265   virtual size_t GetSize () const
00266   { return storage.GetSize(); }
00267   virtual ContainedType const& Get (size_t n) const
00268   { return storage.Get (n); }
00269   virtual ContainedType const& Top () const
00270   { return storage.Top(); }
00271   virtual size_t Find (ContainedType const& which) const
00272   { return storage.Find (which); }
00273   virtual size_t GetIndex (const ContainedType* which) const
00274   { return storage.GetIndex (which); }
00275   virtual bool IsEmpty() const
00276   { return storage.IsEmpty(); }
00277   virtual void GetAll (ContainedType* dest) const
00278   {
00279     for (size_t i = 0; i < storage.GetSize(); i++)
00280       dest[i] = storage[i];
00281   }
00283 };
00284 
00285 #include "csutil/win32/msvc_deprecated_warn_on.h"
00286 
00289 #endif // __CS_CSUTIL_SCFARRAY_H__

Generated for Crystal Space 1.0.2 by doxygen 1.4.7