00001 #ifndef Impala_Core_Geometry_DatabaseReadVxRectangle_h 00002 #define Impala_Core_Geometry_DatabaseReadVxRectangle_h 00003 00004 #include "Persistency/FileLocator.h" 00005 #include "Persistency/RepositoryInFileSystem.h" 00006 #include "Core/Geometry/VxRectangle.h" 00007 #include "Util/Database.h" 00008 #include "Basis/FileName.h" 00009 #include "Util/StringParser.h" 00010 00011 namespace Impala 00012 { 00013 namespace Core 00014 { 00015 namespace Geometry 00016 { 00017 00018 00019 #ifndef REPOSITORY_USED // Here comes the deprecated stuff 00020 template <class BackInsertIterator> 00021 inline void 00022 DatabaseReadVxRectangle(BackInsertIterator bi, String fileName, 00023 Util::Database* db) 00024 { 00025 Util::IOBuffer* buf = db->GetIOBuffer(fileName, true, true, ""); 00026 if (! buf) 00027 return; 00028 00029 bool hasSection = false; 00030 while (buf->Available()) 00031 { 00032 String line = buf->ReadLine(); 00033 if (! line[0]) 00034 continue; 00035 Util::StringParser p(line); 00036 if (p.At("#@") && (p.Contains("section"))) 00037 hasSection = true; 00038 if (p.At("#")) 00039 continue; 00040 VxRectangle vr; 00041 vr.mStartFrame = p.GetInt(); 00042 vr.mEndFrame = p.GetInt(); 00043 vr.mAnno = p.GetString(); 00044 vr.mRect = p.GetRectangle(); 00045 vr.mVideoName = p.GetString(); 00046 if (hasSection) 00047 { 00048 vr.mSection = p.GetString(); 00049 vr.mDir = p.GetString(); 00050 } 00051 else 00052 if (FileNameExt(vr.mVideoName) == "") 00053 vr.mVideoName = vr.mVideoName + ".mpg"; 00054 if (! p.TheEnd()) 00055 vr.mExtra = p.GetString(); 00056 *bi++ = vr; 00057 } 00058 } 00059 #endif // REPOSITORY_USED 00060 00061 template <class BackInsertIterator> 00062 inline void 00063 DatabaseReadVxRectangle(BackInsertIterator bi, 00064 const Persistency::FileLocator& loc) 00065 { 00066 typedef Persistency::RepositoryInFileSystem FS; 00067 Persistency::File file = FS::GetInstance().GetFile(loc, false, false); 00068 Util::IOBuffer* buf = file.GetReadBuffer(true, "");; 00069 if (! buf) 00070 return; 00071 00072 bool hasSection = false; 00073 while (buf->Available()) 00074 { 00075 String line = buf->ReadLine(); 00076 if (! line[0]) 00077 continue; 00078 Util::StringParser p(line); 00079 if (p.At("#@") && (p.Contains("section"))) 00080 hasSection = true; 00081 if (p.At("#")) 00082 continue; 00083 VxRectangle vr; 00084 vr.mStartFrame = p.GetInt(); 00085 vr.mEndFrame = p.GetInt(); 00086 vr.mAnno = p.GetString(); 00087 vr.mRect = p.GetRectangle(); 00088 vr.mVideoName = p.GetString(); 00089 if (hasSection) 00090 { 00091 vr.mSection = p.GetString(); 00092 vr.mDir = p.GetString(); 00093 } 00094 else 00095 if (FileNameExt(vr.mVideoName) == "") 00096 vr.mVideoName = vr.mVideoName + ".mpg"; 00097 if (! p.TheEnd()) 00098 vr.mExtra = p.GetString(); 00099 *bi++ = vr; 00100 } 00101 delete buf; 00102 } 00103 00104 } // namespace Geometry 00105 } // namespace Core 00106 } // namespace Impala 00107 00108 #endif