Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

LayoutData.H

Go to the documentation of this file.
00001 /* _______              __
00002   / ___/ /  ___  __ _  / /  ___
00003  / /__/ _ \/ _ \/  ' \/ _ \/ _ \
00004  \___/_//_/\___/_/_/_/_.__/\___/ 
00005 */
00006 //
00007 // This software is copyright (C) by the Lawrence Berkeley
00008 // National Laboratory.  Permission is granted to reproduce
00009 // this software for non-commercial purposes provided that
00010 // this notice is left intact.
00011 // 
00012 // It is acknowledged that the U.S. Government has rights to
00013 // this software under Contract DE-AC03-765F00098 between
00014 // the U.S.  Department of Energy and the University of
00015 // California.
00016 //
00017 // This software is provided as a professional and academic
00018 // contribution for joint exchange. Thus it is experimental,
00019 // is provided ``as is'', with no warranties of any kind
00020 // whatsoever, no support, no promise of updates, or printed
00021 // documentation. By using this software, you acknowledge
00022 // that the Lawrence Berkeley National Laboratory and
00023 // Regents of the University of California shall have no
00024 // liability with respect to the infringement of other
00025 // copyrights by any part of this software.
00026 //
00027 
00028 #ifndef LAYOUTDATA_H
00029 #define LAYOUTDATA_H
00030 
00031 #include "BoxLayout.H"
00032 #include "DataIterator.H"
00033 
00034 //class ArrayViewData;
00035 
00037 
00064 template<class T> class LayoutData
00065 {
00066 public:
00067 
00068   friend class ArrayViewData;
00069 
00071   LayoutData();
00072 
00074 
00076   LayoutData(const BoxLayout& dp);
00077 
00079   virtual ~LayoutData();
00080 
00082 
00085   virtual void define(const BoxLayout& dp);
00086 
00087   // this approach, of using the iterator itself for indexing is
00088   // my own brilliance.  This way you don't need all the
00089   // crappy [Const][Dependent] Iterators.  It also forces all
00090   // data access to be done through the DataIterator, which will
00091   // know how to talk to KeLP (or other parallel architectures,
00092   // like multithreading, etc).
00093 
00095   DataIterator dataIterator() const;
00096 
00098   const T& operator[](const DataIndex& index) const;
00099 
00101   T& operator[](const DataIndex& index);
00102 
00104   Box box(const DataIndex& index) const;
00105 
00106 
00107   // not really a protection mechanism, since a user can always
00108   // perform a shallow copy of the BoxLayout, and be free to manipulate
00109   // the data in the object.  If you wish to have an actual copy 
00110   // of the BoxLayout, then you need to invoke the clone() method.
00111 
00113   const BoxLayout& boxLayout() const
00114     {
00115       return m_boxLayout;
00116     }
00117 
00118 
00119 protected:
00120 
00121   BoxLayout m_boxLayout;
00122 
00123   // this used to be std::vector<T>, and I could let vector handle
00124   // destruction for me, but vector.resize() absolutely demands that
00125   // I provide a copy constructor for T.  People get uncomfortable when
00126   // I make them provide me with copy constructors.
00127   Vector<T*> m_vector;
00128 
00129   // thinking about making this class self-documenting to a greater degree
00130   // and having the component names also be kept in the class and carried
00131   // around through various transformations.....
00132   //  vector<string> m_componentNames;
00133 
00134 private:
00135 
00136   // disallow copy constructors and assignment operators
00137   // to avoid very hard-to-find performance problems 
00138   LayoutData<T>& operator= (const LayoutData<T>& rhs);
00139   LayoutData(const LayoutData& rhs);
00140 
00141  // handy usage function, tied to the implementation of this class
00142   // as a vector<T*>.  Assumes that m_comps and m_boxLayout have already
00143   // been initialized correctly.  Sets the correct size for the data
00144   // vector, deletes the extra T objects if m_vector is to shorten, and
00145   // performs either construction or define on the remaining T objects.
00146 
00147   void allocate();
00148 
00149 };
00150 
00151 
00152 //======================================================================
00153 //======================================================================
00154 
00155 
00156 
00157 
00158 //========= inline functions ===========================
00159 
00160 // not literally a .H file, but just an experiment in
00161 // having useable, readable headers, while having 
00162 // the dependeny system work properly.  Since LayoutData.H
00163 // now depends on LayoutDataI.H, then changing either
00164 // should cause all code that includes LayoutData.H to be
00165 // recompiled.  This way people can just read the interface
00166 // in this file.  Implementation is put in the *I.H file.
00167 
00168 #include "LayoutDataI.H"
00169 
00170 #endif // LAYOUTDATA_H

Generated on Wed Apr 16 14:26:49 2003 for Chombo by doxygen1.2.16