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 }
00048 else if (ext == "ixs")
00049 {
00050 String setName = options.GetString("imageSet");
00051 Util::Database* db = new Util::Database(setName);
00052 imSet = new ImageSet(db, setName, true);
00053 }
00054 else
00055 {
00056 String fileNameSlashed = StringReplaceAll(fileName, "\\", "/");
00057 StringList pList(fileNameSlashed, '/');
00058 String imName = *(pList.rbegin());
00059 pList.pop_back();
00060 String dirName = *(pList.rbegin());
00061 pList.pop_back();
00062 String section = pList.ToString('/');
00063 Util::Database* db = &Util::Database::GetInstance();
00064 imSet = new ImageSet(db, "tmpSet.txt", false);
00065 imSet->AddFile(imName, section, dirName);
00066 }
00067
00068 if (!imSet)
00069 ILOG_WARN("Construction of image set failed for: " << fileName);
00070 return imSet;
00071 }
00072
00073 #else // REPOSITORY_USED
00074
00075 inline ImageSet*
00076 MakeImageSet(CString setName)
00077 {
00078 CmdOptions& options = CmdOptions::GetInstance();
00079 Persistency::ImageSetLocator loc(setName, options);
00080 return Persistency::ImageSetRepository().Get(loc);
00081 }
00082
00083 #endif // REPOSITORY_USED
00084
00085 }
00086 }
00087 }
00088
00089 #endif