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

VxStructure.h

00001 /*
00002  *  Copyright (c) 2000, University of Amsterdam, The Netherlands.
00003  *  All rights reserved.
00004  *
00005  *  Author(s):
00006  *  Jeroen Vendrig (vendrig@science.uva.nl)
00007  */
00008 
00018 /*
00019  * JV, 03Jan01, increased efficiency, especially getShots() and getEffects().
00020  * JV, 03Jan01, added isSequential
00021  * JV, 04Sep01, made some functions const
00022  */
00023 
00024 #ifndef VxStructure_h
00025 #define VxStructure_h
00026 
00027 #pragma warning( disable : 4786 )  
00028 
00029 
00030 #include <map>
00031 #include <list>
00032 #include "HxString.h"
00033 #include "HxIo.h"
00034 #include "VxSegmentList.h"
00035 
00037 struct VxStructureEval
00038 {
00039     int correct;    // #times that two borders are equal
00040     int missed;     // #times that a border in Truth was not seen in Found
00041     int falseAlarm; // #times that a border was seen in Found, but not in Truth 
00042 };
00043 
00044 
00048 typedef std::map<HxString, VxSegmentList> VxStructureMap;
00049 
00053 #define VXBLOCKS    "blocks"
00054 #define VXSHOTS     "shots"
00055 #define VXEFFECTS   "effects"
00056 #define VXSCENES    "scenes"
00057 
00058 class VxStructure {
00059 public:
00060 // Creation.
00062                             VxStructure();
00063 
00065                             VxStructure(const VxStructure& rhs);
00066 
00076                             VxStructure(HxString& base, 
00077                                 std::vector<HxString> extLevels);
00078 
00080                             ~VxStructure();
00081 
00083     VxStructure&            operator=(const VxStructure& rhs);
00084 
00089     bool                    push(const HxString &levelId, const VxSegmentList& segList);
00090 
00095     bool                    push(const HxString &levelId, const HxString& filename);
00096 
00101     void                    replace(const HxString &levelId, 
00102                                 const VxSegmentList& segList);
00103 
00104 
00105 // Inquiry.
00107     bool                    exist(const HxString& levelId) const;   
00108 
00109     int                     size(const HxString& levelId) const;
00110 
00114     VxSegmentList           get(const HxString& levelId) const;
00115 
00123     VxSegmentList           get(const HxString& levelId, VxSegment timeSpan, 
00124                                 bool complete=false) const;
00125 
00130     VxSegment               getSegment(const HxString& levelId, int index) const;
00131     
00134     VxSegmentList           getWhere(
00135                                 const HxString& levelId, 
00136                                 const HxString& strType, 
00137                                 const int& val) const;
00138     VxSegmentList           getWhere(
00139                                 const HxString& levelId, 
00140                                 const HxString& strType, 
00141                                 const HxString& val) const;
00142 
00150     VxSegmentList           getShots();
00151     VxSegmentList           getEffects();                               
00152 
00155     std::list<HxString>     getLevelNames() const;
00156 
00162     int                     mapsToIndex(
00163                                 const HxString& levelId, VxSegment timeSpan) const;
00164     int                     mapsToIndex(
00165                                 const HxString& levelId, int timeSpan) const;
00166 
00170     VxSegment               mapsToSegment(const HxString& levelId, int timeSpan) const;
00171 
00178     std::list<int>          getSegmentBoundaries(
00179                                 const HxString& levelId, VxSegment timeSpan) const;
00180 
00181 
00187     bool                    isContinuous(const HxString& levelId) const;
00188 
00193     bool                    isSequential(const HxString& levelId) const;
00194 
00200     bool                    isParentOf(
00201                                 const HxString& levelId1, const HxString& levelId2) const;
00202 
00208     bool                    isChildOf(
00209                                 const HxString& levelId1, const HxString& levelId2) const;
00210 
00213     VxStructureEval         compare(
00214                                 const HxString& levelId, 
00215                                 const VxSegmentList& foundTruth) const;
00216 
00217 
00218 // I/O.
00222     STD_OSTREAM&            put(
00223                                 const HxString& levelId, 
00224                                 STD_OSTREAM& os=STD_COUT) const;
00225 
00226 private:
00228     void                    write(const HxString& levelId, const HxString& filename);
00229     bool                    read(const HxString& levelId, const HxString& filename);
00230 
00231     struct VxStructureRep{
00233         VxStructureMap      _map; 
00234         int                 refCount;
00235         VxStructureRep()    { refCount = 1;}        
00236     };
00237 
00238     VxStructureRep*         _data;
00239 
00240 };
00241 
00242 inline STD_OSTREAM&
00243 operator<<(STD_OSTREAM& os, const VxStructure& vs)
00244 { 
00245     
00246     std::list<HxString> sl=vs.getLevelNames();
00247     for (std::list<HxString>::iterator it=sl.begin(); it!=sl.end(); it++)
00248     {
00249         os << "# Level name: " << *it << STD_ENDL;
00250         os << vs.get(*it);
00251     }
00252     
00253     return os;
00254 }
00255 
00256 #endif

Generated on Mon Jan 27 15:48:51 2003 for C++Reference by doxygen1.2.12 written by Dimitri van Heesch, © 1997-2001