00001
00002
00003 #ifndef _included_GridBox_h
00004 #define _included_GridBox_h
00005
00011 #include "DAGHParams.h"
00012 #include "BBox.h"
00013
00014 #include <iosfwd>
00015 #include <cstdlib>
00016
00017 #define GridBoxNULL ((GridBox *) 0)
00018
00025 class GridBox
00026 {
00027 friend std::ostream& operator<<(std::ostream&, const GridBox&);
00028 friend std::ofstream& operator<<(std::ofstream&, const GridBox&);
00029 friend std::ifstream& operator>>(std::ifstream&, GridBox&);
00030 friend std::stringstream& operator<<(std::stringstream&, const GridBox&);
00031 friend std::stringstream& operator>>(std::stringstream&, GridBox&);
00032 friend class GridBoxList;
00033
00035 short int owner;
00037 short int index;
00038
00039
00040
00041
00042
00044 BBox bbox;
00045
00046 public:
00047
00048 inline GridBox(void) : owner(DAGHNoBody), index(DAGHNull) {}
00049
00050 inline GridBox(const int own, const int idx, const BBox& bb)
00051 : owner(own), index(idx), bbox(bb) { }
00052
00053 inline GridBox(GridBox const &other)
00054 : owner(other.owner), index(other.index), bbox(other.bbox) { }
00055
00056 inline ~GridBox(void) {}
00057
00058 inline GridBox const &operator= (GridBox const &other)
00059 { owner=other.owner; index=other.index;
00060 bbox=other.bbox; return (*this); }
00061
00062
00063 inline int operator == (GridBox const &other) const
00064 { return((index == other.index) && (owner == other.owner) && bbox == other.bbox); }
00065 inline int operator != (GridBox const &other) const
00066 { return(!(*this == other)); }
00067
00068 inline void SetGridBox(const int own, const int idx, const BBox& bb)
00069 { owner=own; index=idx; bbox=bb; }
00070
00071
00072 inline int gbOwner(void) const { return (owner); }
00073 inline int gbIndex(void) const { return (index); }
00074 inline int gbRank(void) const { return (bbox.rank); }
00075 inline void gbSetIndex(const int idx) { index = idx; }
00076 inline void gbSetOwner(const int p) { owner = p; }
00077 inline void gbSetBBox(const BBox& bb) { bbox = bb; }
00078
00079 inline const BBox& gbBBox(void) const { return bbox; }
00080 BBox gbBBox(const int olap, const int extgh=0) const;
00081 BBox gbBBox(const short* olap, const int extgh=0) const;
00082
00083
00084
00085
00086
00087
00088
00089
00090 };
00091
00092 std::ostream& operator << (std::ostream& os, const GridBox& gb);
00093 std::ofstream& operator << (std::ofstream& ofs, const GridBox& gb);
00094 std::ifstream& operator >> (std::ifstream& ifs, GridBox& gb);
00095 std::stringstream& operator << (std::stringstream& ofs, const GridBox& gb);
00096
00097 std::stringstream& operator >> (std::stringstream& ifs, GridBox& gb);
00098
00099 #endif
00100
00101
00102