Home || Visual Search || Applications || Architecture || Important Messages || OGL || Src

MakeImageSet.h

Go to the documentation of this file.
00001 #ifndef Impala_Core_ImageSet_MakeImageSet_h
00002 #define Impala_Core_ImageSet_MakeImageSet_h
00003 
00004 #ifndef REPOSITORY_USED // Here comes the deprecated stuff
00005 #include "Basis/CmdOptions.h"
00006 #include "Basis/FileName.h"
00007 #include "Basis/String.h"
00008 #include "Basis/StringList.h"
00009 #include "Util/Database.h"
00010 #include "Core/ImageSet/ImageSet.h"
00011 #else // REPOSITORY_USED
00012 #include "Persistency/ImageSetRepository.h"
00013 #endif // REPOSITORY_USED
00014 
00015 namespace Impala
00016 {
00017 namespace Core
00018 {
00019 namespace ImageSet
00020 {
00021 
00022 
00023 #ifndef REPOSITORY_USED // Here comes the deprecated stuff
00024 
00025 inline ImageSet*
00026 MakeImageSet(CString fileName, Util::Database* parentDb = 0)
00027 {
00028     ILOG_VAR("Impala.Core.ImageSet.MakeImageSet");
00029 
00030     if (fileName.empty())
00031     {
00032         ILOG_WARN("Construction of image set not possible without a file name");
00033         return 0;
00034     }
00035 
00036     CmdOptions& options = CmdOptions::GetInstance();
00037     String ext = FileNameExt(fileName);
00038     ImageSet* imSet;
00039     if (ext == "txt")
00040     {
00041         Util::Database* db = parentDb;
00042         if (db == 0)
00043             db = new Util::Database(fileName);
00044         if (db->GetFilePath("ImageData", fileName, false, false).empty())
00045             return 0;
00046         imSet = new ImageSet(db, fileName, true);
00047         // Make ImageSet also Repository compatible
00048         Persistency::ImageSetLocator loc(fileName, options);
00049         imSet->SetProtocolAndHost(loc.GetProtocolAndHost());
00050         imSet->SetImageSetLocator(loc);
00051     }
00052     else if (ext == "ixs")
00053     {
00054         String setName = options.GetString("imageSet");
00055         Util::Database* db = new Util::Database(setName);
00056         imSet = new ImageSet(db, setName, true);
00057     }
00058     else
00059     {
00060         String fileNameSlashed = StringReplaceAll(fileName, "\\", "/");
00061         StringList pList(fileNameSlashed, '/');
00062         String imName = *(pList.rbegin());
00063         pList.pop_back();
00064         String dirName = *(pList.rbegin());
00065         pList.pop_back();
00066         String section = pList.ToString('/');
00067         Util::Database* db = &Util::Database::GetInstance();
00068         imSet = new ImageSet(db, "tmpSet.txt", false);
00069         imSet->AddFile(imName, FileNameConcat(section, dirName));
00070     }
00071 
00072     if (!imSet)
00073         ILOG_WARN("Construction of image set failed for: " << fileName);
00074     return imSet;
00075 }
00076 
00077 #else // REPOSITORY_USED
00078 
00079 inline ImageSet*
00080 MakeImageSet(CString setName)
00081 {
00082     ILOG_VAR("Impala.Core.ImageSet.MakeImageSet");
00083     if (setName.empty())
00084     {
00085         ILOG_WARN("Construction of image set not possible without a name");
00086         return 0;
00087     }
00088     CmdOptions& options = CmdOptions::GetInstance();
00089     Persistency::ImageSetLocator loc(setName, options);
00090     return Persistency::ImageSetRepository().Get(loc);
00091 }
00092 
00093 // This is a special case for ImageSets that belong to a VideoSet, e.g.
00094 // keyframes, thumbnails, and stills.
00095 inline ImageSet*
00096 MakeImageSet(CString setName, const Persistency::Locator& vidSetLoc)
00097 {
00098     ILOG_VAR("Impala.Core.ImageSet.MakeImageSet");
00099     if (setName.empty())
00100     {
00101         ILOG_WARN("Construction of image set not possible without a name");
00102         return 0;
00103     }
00104     Persistency::ImageSetLocator loc(vidSetLoc, setName);
00105     return Persistency::ImageSetRepository().Get(loc);
00106 }
00107 
00108 #endif // REPOSITORY_USED
00109 
00110 } // namespace ImageSet
00111 } // namespace Core
00112 } // namespace Impala
00113 
00114 #endif

Generated on Thu Jan 13 09:04:31 2011 for ImpalaSrc by  doxygen 1.5.1