Horus Doc || C++ Reference || Class Overview   Pixels   Images   Detector   Geometry   Registry || Doxygen's quick Index  

HxImageList.h

00001 /*
00002  *  Copyright (c) 1998, University of Amsterdam, The Netherlands.
00003  *  All rights reserved.
00004  *
00005  *  Author(s):
00006  *  Jan-Mark Geusebroek (mark@wins.uva.nl)
00007  */
00008 
00009 #ifndef HxImageList_h
00010 #define HxImageList_h
00011 
00012 #include <list>
00013 
00014 #include "HxImageRep.h"
00015 
00016 
00019 class HxImageList {
00020 public:
00021     typedef std::list<HxImageRep>::const_iterator const_iterator;
00022     typedef std::list<HxImageRep>::iterator iterator;
00023 
00025                         HxImageList();
00026                         HxImageList(HxImageRep e);
00027                         HxImageList(HxImageRep e1, HxImageRep e2);
00028                         HxImageList(HxImageRep e1, HxImageRep e2, HxImageRep e3);
00029                         HxImageList(HxImageRep e1, HxImageRep e2, HxImageRep e3,
00030                             HxImageRep e4);
00031                         HxImageList(HxImageRep e1, HxImageRep e2, HxImageRep e3,
00032                             HxImageRep e4, HxImageRep e5);
00033 
00034                         /* add more elements with operator '+' */
00035 
00037                         HxImageList(const HxImageList& l);
00038 
00040                         ~HxImageList();
00041 
00042     HxImageList&        operator=(const HxImageList& l);
00043     HxImageRep&         operator[](const int i);
00044 
00046     HxImageData**       pointees() const;
00047     int                 nImages() const;
00048     int                 size() const;
00049     iterator            begin();
00050     iterator            end();
00051     const_iterator      begin() const;
00052     const_iterator      end() const;
00053 
00054     friend HxImageList  operator+(const HxImageList& l, const HxImageRep& e);
00055     friend HxImageList  operator+(const HxImageRep& e, const HxImageList& l);
00056     friend HxImageList  operator+(const HxImageList& l1, const HxImageList& l2);
00057     void        operator+=(const HxImageRep& e);
00058 
00060     HxImageList         unaryPixOp(HxString upoName,
00061                             HxTagList& tags = HxMakeTagList()) const;
00062 
00064     HxImageList         binaryPixOp(const HxImageRep arg, HxString bpoName,
00065                             HxTagList& tags = HxMakeTagList()) const;
00066 
00068     HxImageList         binaryPixOp(const HxValue arg, HxString bpoName,
00069                             HxTagList& tags = HxMakeTagList()) const;
00070 
00073     HxImageRep          multiPixOp(HxString mpoName,
00074                             HxTagList& tags = HxMakeTagList());
00075 
00078     HxImageList         MNPixOp( HxString mpoName, 
00079                             HxTagList& tags = HxMakeTagList());
00080 
00081 private:
00082     std::list<HxImageRep> _ims;
00083 };
00084 
00085 inline
00086 HxImageList::HxImageList()
00087 {
00088 }
00089 
00090 inline
00091 HxImageList::HxImageList(HxImageRep e)
00092 {
00093     _ims.push_back(e);
00094 }
00095 
00096 inline
00097 HxImageList::HxImageList(HxImageRep e1, HxImageRep e2)
00098 {
00099     _ims.push_back(e1);
00100     _ims.push_back(e2);
00101 }
00102 
00103 inline
00104 HxImageList::HxImageList(HxImageRep e1, HxImageRep e2, HxImageRep e3)
00105 {
00106     _ims.push_back(e1);
00107     _ims.push_back(e2);
00108     _ims.push_back(e3);
00109 }
00110 
00111 inline
00112 HxImageList::HxImageList(HxImageRep e1, HxImageRep e2, HxImageRep e3,
00113     HxImageRep e4)
00114 {
00115     _ims.push_back(e1);
00116     _ims.push_back(e2);
00117     _ims.push_back(e3);
00118     _ims.push_back(e4);
00119 }
00120 
00121 inline
00122 HxImageList::HxImageList(HxImageRep e1, HxImageRep e2, HxImageRep e3,
00123     HxImageRep e4, HxImageRep e5)
00124 {
00125     _ims.push_back(e1);
00126     _ims.push_back(e2);
00127     _ims.push_back(e3);
00128     _ims.push_back(e4);
00129     _ims.push_back(e5);
00130 }
00131 
00132 inline
00133 HxImageList::HxImageList(const HxImageList& l)
00134 {
00135     _ims = l._ims;
00136 }
00137 
00138 inline
00139 HxImageList::~HxImageList()
00140 {
00141 }
00142 
00143 inline HxImageList&
00144 HxImageList::operator=(const HxImageList& l)
00145 {
00146     if (&l != this)
00147         _ims = l._ims;
00148     return *this;
00149 }
00150 
00151 inline HxImageRep&
00152 HxImageList::operator[](const int i)
00153 {
00154     static HxImageRep empty;
00155 
00156     HxImageList::iterator it;
00157 
00158     int j = 0;
00159 
00160     for (it = _ims.begin(); (it != _ims.end()) && (j != i); it++)
00161         j++;
00162 
00163     if (it != _ims.end())
00164         return *it;
00165 
00166     return empty;
00167 }
00168 
00169 inline int
00170 HxImageList::size() const
00171 {
00172     return _ims.size();
00173 }
00174 
00175 inline HxImageList::const_iterator 
00176 HxImageList::begin() const
00177 {
00178     return _ims.begin();
00179 }
00180 
00181 inline HxImageList::const_iterator 
00182 HxImageList::end() const
00183 {
00184     return _ims.end();
00185 }
00186 
00187 inline HxImageList::iterator 
00188 HxImageList::begin()
00189 {
00190     return _ims.begin();
00191 }
00192 
00193 inline HxImageList::iterator 
00194 HxImageList::end()
00195 {
00196     return _ims.end();
00197 }
00198 
00199 inline HxImageList
00200 HxImageList::unaryPixOp(HxString upoName, HxTagList& tags) const
00201 {
00202     HxImageList::const_iterator i;
00203     HxImageList res;
00204 
00205     for (i = _ims.begin(); i != _ims.end(); i++)
00206         res += (*i).unaryPixOp(upoName, tags);
00207     
00208     return res;
00209 }
00210 
00211 inline HxImageList
00212 HxImageList::binaryPixOp(const HxImageRep arg, HxString bpoName,
00213     HxTagList& tags) const
00214 {
00215     HxImageList::const_iterator i;
00216     HxImageList res;
00217 
00218     for (i = _ims.begin(); i != _ims.end(); i++)
00219         res += (*i).binaryPixOp(arg, bpoName, tags);
00220     
00221     return res;
00222 }
00223 
00224 inline HxImageList
00225 HxImageList::binaryPixOp(const HxValue arg, HxString bpoName,
00226     HxTagList& tags) const
00227 {
00228     HxImageList::const_iterator i;
00229     HxImageList res;
00230 
00231     for (i = _ims.begin(); i != _ims.end(); i++)
00232         res += (*i).binaryPixOp(arg, bpoName, tags);
00233     
00234     return res;
00235 }
00236 
00237 inline HxImageRep
00238 HxImageList::multiPixOp(HxString mpoName, HxTagList& tags)
00239 {
00240     HxImageRep im, res;
00241 
00242     im = _ims.front();
00243     _ims.pop_front();
00244 
00245     res = im.multiPixOp(*this, mpoName, tags);
00246 
00247     _ims.push_front(im);
00248 
00249     return res;
00250 }
00251 
00252 inline HxImageList
00253 HxImageList::MNPixOp(HxString mpoName, HxTagList& tags)
00254 {
00255     HxImageRep im;
00256     HxImageList res;
00257 
00258     im = _ims.front();
00259     _ims.pop_front();
00260 
00261     res = im.MNPixOp(*this, mpoName, tags);
00262 
00263     _ims.push_front(im);
00264 
00265     return res;
00266 }
00267 
00268 inline HxImageList
00269 operator+(const HxImageList l, const HxImageRep& e)
00270 {
00271     HxImageList tmp = l;
00272     tmp += e;
00273     return tmp;
00274 }
00275 
00276 inline HxImageList
00277 operator+(const HxImageRep& e, const HxImageList& l)
00278 {
00279     HxImageList tmp = l;
00280     tmp._ims.push_front(e);
00281     return tmp;
00282 }
00283 
00284 inline void
00285 HxImageList::operator+=(const HxImageRep& e)
00286 {
00287     _ims.push_back(e);
00288 }
00289 
00290 inline HxImageList
00291 operator+(const HxImageList& l1, const HxImageList& l2)
00292 {
00293     HxImageList n;
00294     HxImageList::const_iterator i;
00295 
00296     for (i = l1._ims.begin(); i != l1._ims.end(); i++)
00297         n._ims.push_back(*i);
00298     for (i = l2._ims.begin(); i != l2._ims.end(); i++)
00299         n._ims.push_back(*i);
00300 
00301     return n;
00302 }
00303 
00304 #endif

Generated on Tue Feb 3 14:18:35 2004 for C++Reference by doxygen1.2.12 written by Dimitri van Heesch, © 1997-2001