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 
00054 template<typename IF, 
00055   typename Backend = csArray<typename IF::ContainedType> >
00056 class scfArray : 
00057   public scfImplementation1<scfArray<IF, Backend>, IF>
00058 {
00059   typedef scfImplementation1<scfArray<IF, Backend>, IF> scfImplementationType;
00060   typedef typename IF::ContainedType ContainedType;
00061 public:
00063   Backend storage;
00064 
00066 
00067   scfArray () : scfImplementationType (this) {}
00068   scfArray (iBase* scfParent) : scfImplementationType (this, scfParent) {}
00070 
00071 
00072   scfArray (const Backend& storage) : scfImplementationType (this), 
00073     storage (storage) {}
00074   scfArray (const Backend& storage, iBase* scfParent) : 
00075     scfImplementationType (this, scfParent), storage (storage) {}
00077 
00080   virtual size_t GetSize () const
00081   { return storage.GetSize(); }
00082   virtual ContainedType const& Get (size_t n) const
00083   { return storage.Get (n); }
00084   virtual ContainedType const& Top () const
00085   { return storage.Top(); }
00086   virtual size_t Find (ContainedType const& which) const
00087   { return storage.Find (which); }
00088   virtual size_t GetIndex (const ContainedType* which) const
00089   { return storage.GetIndex (which); }
00090   virtual bool IsEmpty() const
00091   { return storage.IsEmpty(); }
00092   virtual void GetAll (ContainedType* dest) const
00093   {
00094     for (size_t i = 0; i < storage.GetSize(); i++)
00095       dest[i] = storage[i];
00096   }
00101   virtual ContainedType& Get (size_t n)
00102   { return storage.Get (n); }
00103   virtual ContainedType& Top ()
00104   { return storage.Top(); }
00109   virtual void SetSize (size_t n, ContainedType const& what)
00110   { storage.SetSize (n, what); }
00111   virtual void SetSize (size_t n)
00112   { storage.SetSize (n); }
00113   virtual ContainedType& GetExtend (size_t n)
00114   { return storage.GetExtend (n); }
00115   virtual void Put (size_t n, ContainedType const& what)
00116   { storage.Put (n, what); }
00117   virtual size_t Push (ContainedType const& what)
00118   { return storage.Push (what); }
00119   virtual size_t PushSmart (ContainedType const& what)
00120   { return storage.PushSmart (what); }
00121   virtual ContainedType Pop ()
00122   { return storage.Pop (); }
00123   virtual bool Insert (size_t n, ContainedType const& item)
00124   { return storage.Insert (n, item); }
00125   virtual void DeleteAll ()
00126   { storage.DeleteAll(); }
00127   virtual void Truncate (size_t n)
00128   { storage.Truncate(n); }
00129   virtual void Empty ()
00130   { storage.Empty(); }
00131   virtual bool DeleteIndex (size_t n)
00132   { return storage.DeleteIndex  (n); }
00133   virtual bool DeleteIndexFast (size_t n)
00134   { return storage.DeleteIndexFast  (n); }
00135   virtual bool Delete (ContainedType const& item)
00136   { return storage.Delete (item); }
00138 };
00139 
00149 template<typename IF, typename Backend>
00150 class scfArrayWrap : 
00151   public scfImplementation1<scfArrayWrap<IF, Backend>, IF>
00152 {
00153   typedef scfImplementation1<scfArrayWrap<IF, Backend>, IF> 
00154     scfImplementationType;
00155   typedef typename IF::ContainedType ContainedType;
00156 public:
00158   Backend& storage;
00159 
00161 
00162   scfArrayWrap (Backend& storage) : scfImplementationType (this), 
00163     storage (storage) {}
00164   scfArrayWrap (Backend& storage, iBase* scfParent) : 
00165     scfImplementationType (this, scfParent), storage (storage) {}
00167 
00170   virtual size_t GetSize () const
00171   { return storage.GetSize(); }
00172   virtual ContainedType const& Get (size_t n) const
00173   { return storage.Get (n); }
00174   virtual ContainedType const& Top () const
00175   { return storage.Top(); }
00176   virtual size_t Find (ContainedType const& which) const
00177   { return storage.Find (which); }
00178   virtual size_t GetIndex (const ContainedType* which) const
00179   { return storage.GetIndex (which); }
00180   virtual bool IsEmpty() const
00181   { return storage.IsEmpty(); }
00182   virtual void GetAll (ContainedType* dest) const
00183   {
00184     for (size_t i = 0; i < storage.GetSize(); i++)
00185       dest[i] = storage[i];
00186   }
00191   virtual ContainedType& Get (size_t n)
00192   { return storage.Get (n); }
00193   virtual ContainedType& Top ()
00194   { return storage.Top(); }
00199   virtual void SetSize (size_t n, ContainedType const& what)
00200   { storage.SetSize (n, what); }
00201   virtual void SetSize (size_t n)
00202   { storage.SetSize (n); }
00203   virtual ContainedType& GetExtend (size_t n)
00204   { return storage.GetExtend (n); }
00205   virtual void Put (size_t n, ContainedType const& what)
00206   { storage.Put (n, what); }
00207   virtual size_t Push (ContainedType const& what)
00208   { return storage.Push (what); }
00209   virtual size_t PushSmart (ContainedType const& what)
00210   { return storage.PushSmart (what); }
00211   virtual ContainedType Pop ()
00212   { return storage.Pop (); }
00213   virtual bool Insert (size_t n, ContainedType const& item)
00214   { return storage.Insert (n, item); }
00215   virtual void DeleteAll ()
00216   { storage.DeleteAll(); }
00217   virtual void Truncate (size_t n)
00218   { storage.Truncate(n); }
00219   virtual void Empty ()
00220   { storage.Empty(); }
00221   virtual bool DeleteIndex (size_t n)
00222   { return storage.DeleteIndex  (n); }
00223   virtual bool DeleteIndexFast (size_t n)
00224   { return storage.DeleteIndexFast  (n); }
00225   virtual bool Delete (ContainedType const& item)
00226   { return storage.Delete (item); }
00228 };
00229 
00238 template<typename IF, typename Backend>
00239 class scfArrayWrapConst : 
00240   public scfImplementation1<scfArrayWrapConst<IF, Backend>, IF>
00241 {
00242   typedef scfImplementation1<scfArrayWrapConst<IF, Backend>, IF> 
00243     scfImplementationType;
00244   typedef typename IF::ContainedType ContainedType;
00245 public:
00247   const Backend& storage;
00248 
00250 
00251   scfArrayWrapConst (const Backend& storage) : scfImplementationType (this), 
00252     storage (storage) {}
00253   scfArrayWrapConst (const Backend& storage, iBase* scfParent) : 
00254     scfImplementationType (this, scfParent), storage (storage) {}
00256 
00259   virtual size_t GetSize () const
00260   { return storage.GetSize(); }
00261   virtual ContainedType const& Get (size_t n) const
00262   { return storage.Get (n); }
00263   virtual ContainedType const& Top () const
00264   { return storage.Top(); }
00265   virtual size_t Find (ContainedType const& which) const
00266   { return storage.Find (which); }
00267   virtual size_t GetIndex (const ContainedType* which) const
00268   { return storage.GetIndex (which); }
00269   virtual bool IsEmpty() const
00270   { return storage.IsEmpty(); }
00271   virtual void GetAll (ContainedType* dest) const
00272   {
00273     for (size_t i = 0; i < storage.GetSize(); i++)
00274       dest[i] = storage[i];
00275   }
00277 };
00278 
00281 #endif // __CS_CSUTIL_SCFARRAY_H__

Generated for Crystal Space 1.2.1 by doxygen 1.5.3