#
creaImageIOGimmick
creaImageIOSynchronizer
+ creaImageIOTimestampDatabaseHandler
# Abstract views
creaImageIOGimmickView
// Sets the current directory to the home dir
mCurrentDirectory = GetHomeDirectory();
mSynchronizer=0;
+
// Create local database handler
mLocalDatabase = new SQLiteTreeHandler(GetLocalDatabasePath());
// Add it to the TreeHandlerMap
mTreeHandlerMap["Local database"] = mLocalDatabase;
-
// Create or open local database
if (! boost::filesystem::exists( GetLocalDatabasePath() ) )
{
}
}
+
+
+ // Creates files and directories database
+ mTimestampDatabase = new TimestampDatabaseHandler(GetTimestampDatabasePath());
+ // Create or open local database
+ if (! boost::filesystem::exists( GetTimestampDatabasePath() ) )
+ {
+ std::string mess = "Timestamp database '";
+ mess += GetTimestampDatabasePath();
+ mess += "' does not exist : creating it";
+ GimmickMessage(1,mess<<std::endl);
+
+ if ( ! mTimestampDatabase->Create() )
+ {
+ GimmickError("ERROR CREATING '"<<GetTimestampDatabasePath()<<"'");
+ }
+
+ }
+ else
+ {
+ /// Open and test it
+ GimmickMessage(1,"Opening Timestamp database '"
+ <<GetTimestampDatabasePath()<<"' "
+ <<std::endl);
+ if ( ! mTimestampDatabase->Open() )
+ {
+ GimmickError("ERROR OPENING '"<<GetTimestampDatabasePath()<<"'");
+ }
+
+ }
+
}
//================================================================
void Gimmick::Finalize()
{
delete mLocalDatabase;
+ delete mTimestampDatabase;
}
//==============================================================
}
return mLocalDatabasePath;
}
+
+ //================================================================
+
+ //================================================================
+ const std::string& Gimmick::GetTimestampDatabasePath()
+ {
+ if (mTimestampDatabasePath.size()==0)
+ {
+ mTimestampDatabasePath = GetUserSettingsDirectory();
+ mTimestampDatabasePath += "timestamp_database.sqlite3";
+ boost::algorithm::replace_all( mTimestampDatabasePath,
+ INVALID_FILE_SEPARATOR ,
+ VALID_FILE_SEPARATOR);
+ }
+ return mTimestampDatabasePath;
+ }
//========================================================================
//========================================================================
//========================================================================
//========================================================================
- /// Add a file to the local database
+ /// Returns the tree handler with the given name
TreeHandler* Gimmick::GetTreeHandler(const std::string& name) const
{
TreeHandlerMapType::const_iterator i;
return i->second;
}
+ //========================================================================
+ ///Returns the timestamp database handler
+ TimestampDatabaseHandler* Gimmick::GetTimestampDatabase() const
+ {
+ return mTimestampDatabase;
+ }
+
//========================================================================
/// Add the files to the tree handler
GimmickMessage(2,"Adding files to '"<<d<<"'"<<std::endl);
mImageAdder.SetTreeHandler(GetTreeHandler(d));
+ mImageAdder.SetTimestampHandler(mTimestampDatabase);
mImageAdder.AddFiles(filenames);
}
TreeHandler * handler=GetTreeHandler(d);
mImageAdder.SetTreeHandler(handler);
+ mImageAdder.SetTimestampHandler(mTimestampDatabase);
mImageAdder.AddDirectory(f,recurse);
//Synchronize(true, handler);
#include <creaImageIOSQLiteTreeHandler.h>
#include <creaImageIOTreeHandlerImageAdder.h>
+#include <creaImageIOTimestampDatabaseHandler.h>
#include <creaImageIOSynchronizer.h>
namespace creaImageIO
/// Returns the TreeHandler with a given name
TreeHandler* GetTreeHandler(const std::string& name) const;
+
+ /// Returns the TimestampDatabase
+ TimestampDatabaseHandler* GetTimestampDatabase() const;
///
SQLiteTreeHandler* GetLocalDatabase() { return mLocalDatabase; }
const std::string& GetUserSettingsDirectory();
void CreateUserSettingsDirectory();
const std::string& GetLocalDatabasePath();
+ const std::string& GetTimestampDatabasePath();
//=============================================
private:
SQLiteTreeHandler* mLocalDatabase;
+ TimestampDatabaseHandler* mTimestampDatabase;
TreeHandlerMapType mTreeHandlerMap;
Synchronizer* mSynchronizer;
std::string mHomeDirectory;
std::string mUserSettingsDirectory;
std::string mLocalDatabasePath;
+ std::string mTimestampDatabasePath;
TreeHandlerImageAdder mImageAdder;
};
i!= mGimmick->GetTreeHandlerMap().end();
++i)
{
- this->CreateTreeView(i->second);
+ this->CreateTreeView(i->second, mGimmick->GetTimestampDatabase());
}
}
//======================================================================
void CreateTreeViews();
/// Create the tree view for TreeHandler provided
- virtual void CreateTreeView( TreeHandler*)
+ virtual void CreateTreeView( TreeHandler*, TimestampDatabaseHandler* )
{ GimmickError("INTERNAL ERROR : CreateTreeView not implemented"); }
/// Updates the TreeView of given name from level l to bottom
<<"' in level "<< GetTree().GetLevelDescriptor(node->GetLevel()).GetName()
<<std::endl);
- Node::ChildrenListType::iterator i;
- for (i = node->GetChildrenList().begin();
- i != node->GetChildrenList().end();
- i++)
- {
- DBRecursiveRemoveNode((*i));
- }
+
+ if(node->GetNumberOfChildren()!=0)
+ {
+ Node::ChildrenListType::iterator i;
+ for (i = node->GetChildrenList().begin();
+ i != node->GetChildrenList().end();
+ i++)
+ {
+ DBRecursiveRemoveNode((*i));
+ }
+ }
+ else if(node->GetLevel()<GetTree().GetNumberOfLevels()-1)
+ {
+ DBRecursiveRemoveNode(node->GetLevel()+1,node->GetAttribute("ID"));
+ }
+ }
+
+ //=====================================================================
+ void SQLiteTreeHandler::DBRecursiveRemoveNode(int level, std::string parentId)
+ {
+ std::stringstream out;
+ std::stringstream result;
+ out<<"SELECT ID FROM "<<GetTree().GetLevelDescriptor(level).GetName()<<" WHERE PARENT_ID='"<<parentId<<"'";
+
+ CppSQLite3Query q;
+ QUERYDB(out.str(),q);
+
+ while (!q.eof())
+ {
+ for (int fld = 0; fld < q.numFields(); fld++)
+ {
+ result<<q.getStringField(fld)<<"#";
+ }
+ q.nextRow();
+ }
+ std::string res=result.str();
+ size_t ini=0;
+ size_t fin=0;
+ while(fin<res.size()-1)
+ {
+ fin=res.find('#',ini);
+ DBDelete(GetTree().GetLevelDescriptor(level).GetName(),"ID",res.substr(ini,fin-ini));
+ if(level<GetTree().GetNumberOfLevels()-1)
+ {
+ DBRecursiveRemoveNode(level+1,res.substr(ini,fin-ini));
+ }
+ ini=fin+1;
+ }
+
+
}
//=====================================================================
void DBDelete(std::string levelDescriptor, std::string key, std::string value);
//======================================================================
+ //======================================================================
/// Recursively Removes the nodes whose parent is given as a parameter
void DBRecursiveRemoveNode(tree::Node* node);
+ /// Recursively Removes the nodes found in the given level with the given parent id
+ void DBRecursiveRemoveNode(int level, std::string parentId);
+
+ //======================================================================
+
/*
///
int DBQueryNumberOfChildren(tree::Node* n);
--- /dev/null
+#include <creaImageIOTimestampDatabaseHandler.h>
+#include <creaImageIOSystem.h>
+
+#include "CppSQLite3.h"
+
+#include <sys/stat.h>
+
+#include <deque>
+
+#include "wx/wx.h"
+#include <wx/dir.h>
+#include <wx/filename.h>
+
+#include <creaWx.h>
+using namespace crea;
+
+#include <boost/filesystem.hpp>
+#include <boost/algorithm/string/replace.hpp>
+
+namespace creaImageIO
+{
+ using namespace tree;
+ //=============================================================
+ TimestampDatabaseHandler::TimestampDatabaseHandler(const std::string& filename)
+ : mFileName(filename)
+ {
+ mDB = new CppSQLite3DB;
+ GimmickMessage(1,"SQLite version : "
+ <<std::string(mDB->SQLiteVersion())<< std::endl);
+ }
+ //=============================================================
+
+ //=============================================================
+ TimestampDatabaseHandler::~TimestampDatabaseHandler()
+ {
+ delete mDB;
+ }
+ //=============================================================
+ //=====================================================================
+ bool TimestampDatabaseHandler::Open()
+ {
+ return DBOpen();
+ }
+
+ //=====================================================================
+ bool TimestampDatabaseHandler::Create()
+ {
+ return DBCreate();
+ }
+ //=====================================================================
+
+
+ //=====================================================================
+ bool TimestampDatabaseHandler::Close()
+ {
+ return true;
+ }
+ //=====================================================================
+
+
+ //=====================================================================
+ bool TimestampDatabaseHandler::Destroy()
+ {
+ return false;
+ }
+
+
+
+
+
+
+ //=====================================================================
+ // SQLite DB specific methods
+ //=====================================================================
+ //=====================================================================
+#define QUERYTIMESTAMPDB(QUER,RES) \
+ try \
+ { \
+ GimmickMessage(2,"SQL query: '"<<QUER<<"'"<<std::endl); \
+ RES = mDB->execQuery(QUER.c_str()); \
+ } \
+ catch (CppSQLite3Exception& e) \
+ { \
+ GimmickError("SQLite query '"<<QUER<<"' : " \
+ << e.errorCode() << ":" \
+ << e.errorMessage() ); \
+ } \
+ //=====================================================================
+#define UPDATETIMESTAMPDB(UP) \
+ try \
+ { \
+ GimmickMessage(2,"SQL update: '"<<UP<<"'"<<std::endl); \
+ mDB->execDML(UP.c_str()); \
+ } \
+ catch (CppSQLite3Exception& e) \
+ { \
+ GimmickError("SQLite update '"<<UP<<"' Error : " \
+ << e.errorCode() << ":" \
+ << e.errorMessage() ); \
+ }
+ //=====================================================================
+
+
+ //=====================================================================
+ bool TimestampDatabaseHandler::DBOpen()
+ {
+ GimmickMessage(1,"Opening SQLite database '"<<GetFileName()
+ <<"' ... "<<std::endl);
+ // OPENING FILE
+ if (!boost::filesystem::exists(GetFileName()))
+ {
+ return false;
+ }
+
+ try
+ {
+ mDB->open(GetFileName().c_str());
+ }
+ catch (CppSQLite3Exception& e)
+ {
+ GimmickError("Opening '"<<GetFileName()<<"' : "
+ << e.errorCode() << ":"
+ << e.errorMessage());
+ return false;
+ }
+
+ GimmickDebugMessage(1,"Opening SQLite database '"<<GetFileName()
+ <<"' ... OK"<<std::endl);
+ return true;
+ }
+ //=====================================================================
+
+ //=====================================================================
+ bool TimestampDatabaseHandler::DBCreate()
+ {
+ GimmickMessage(1,"Creating SQLite database '"<<GetFileName()
+ <<"' ... "<<std::endl);
+
+ if (boost::filesystem::exists(GetFileName()))
+ {
+ GimmickError(GetFileName()<<"' : "
+ << "file already exists");
+ return false;
+ }
+
+ // OPENING
+ try
+ {
+ mDB->open(GetFileName().c_str());
+ }
+ catch (CppSQLite3Exception& e)
+ {
+ GimmickError(e.errorCode() << ":"
+ << e.errorMessage() <<std::endl);
+ return false;
+ }
+
+
+ // CREATING TABLES
+
+ std::string command;
+
+
+ command = "CREATE TABLE ";
+ command += "FILES";
+ command += "\n(\nID INTEGER PRIMARY KEY";
+ command += ",\nPARENT_ID int not null";
+ command += ",\nPATH text";
+ command += ",\nLastModified datetext";
+ command += ",\nLastRead datetext";
+ command += ",\nconstraint FK_PARENT foreign key (PARENT_ID) references ";
+ command += "FILES";
+ command += "(ID) on delete restrict on update restrict";
+
+ command += "\n)";
+ UPDATETIMESTAMPDB(command);
+
+ return true;
+ }
+
+
+
+ //=====================================================================
+ void TimestampDatabaseHandler::CleanName(std::string& str) const
+ {
+ size_t pos;
+ do
+ {
+ pos = str.find('\\');
+ if (pos!=-1)
+ {
+ str.replace(pos, 1, "/");
+ }
+ }
+ while (pos!=-1);
+ }
+
+
+ //=====================================================================
+
+ bool TimestampDatabaseHandler::AddDirectory(const std::string& parent,
+ const std::string& path,
+ const time_t lastModif,
+ const time_t lastRead)
+ {
+ bool valid=false;
+ std::string par=parent.c_str();
+ std::string pat=path.c_str();
+ CleanName(par);
+ CleanName(pat);
+
+ std::string pathId=IsIndexed(pat);
+ //Case: It is a root parent
+ if(parent.compare("")==0)
+ {
+ if(pathId.compare("")==0)
+ {
+ AddFile(pat,lastModif,lastRead);
+ valid=true;
+ }
+ else
+ {
+ valid=CheckTimestamp(pathId, lastModif);
+ }
+ }
+ else
+ {
+ std::string parentId=IsIndexed(par);
+ //Case: Parent is not in database
+ if(parentId.compare("")==0)
+ {
+ AddFile(par,lastModif,lastRead);
+ parentId=IsIndexed(par);
+ }
+
+ //Case path is not in database
+ if(pathId.compare("")==0)
+ {
+ AddFile(parentId,pat,lastModif,lastRead);
+ valid=true;
+ }
+ //Parent and path are in the database
+ else
+ {
+ SetAttribute("PARENT_ID",parentId,"ID", pathId);
+ valid=CheckTimestamp(pathId, lastModif);
+ }
+ }
+ return valid;
+
+ }
+
+ //=====================================================================
+
+ void TimestampDatabaseHandler::AddFile(const std::string& path, const time_t lastModif, const time_t lastRead)
+ {
+ std::stringstream out;
+ out<<"INSERT INTO FILES (PARENT_ID,PATH,LastModified,LastRead) VALUES(0,'"<<path<<"',";
+ out<<lastModif<<","<<lastRead<<");";
+ UPDATETIMESTAMPDB(out.str());
+
+ }
+
+ //=====================================================================
+
+ void TimestampDatabaseHandler::AddFile(const std::string& parentId,
+ const std::string& path,
+ const time_t lastModif,
+ const time_t lastRead)
+ {
+ std::stringstream out;
+ out<<"INSERT INTO FILES (PARENT_ID,PATH,LastModified,LastRead) VALUES("<<parentId<<",'"<<path<<"',";
+ out<<lastModif<<","<<lastRead<<");";
+ UPDATETIMESTAMPDB(out.str());
+ }
+
+ //=====================================================================
+ std::string TimestampDatabaseHandler::IsIndexed(const std::string& path)
+ {
+ std::stringstream out;
+ std::stringstream result;
+ out<<"SELECT ID FROM FILES WHERE PATH='"<<path<<"'";
+
+ CppSQLite3Query q;
+ QUERYTIMESTAMPDB(out.str(),q);
+
+
+ while (!q.eof())
+ {
+ for (int fld = 0; fld < q.numFields(); fld++)
+ {
+ result<<q.getStringField(fld);
+ }
+ q.nextRow();
+ }
+
+ return result.str();
+ }
+
+ //=====================================================================
+ void TimestampDatabaseHandler::SetAttribute(const std::string& attName,
+ const std::string& attValue,
+ const std::string& searchParam,
+ const std::string& searchValue)
+ {
+ std::string sql = "UPDATE FILES SET ";
+ sql += attName;
+ sql += " = '";
+ sql += attValue;
+ sql += "' WHERE ";
+ sql += searchParam;
+ sql += " = '";
+ sql += searchValue;
+ sql += "'";
+ UPDATETIMESTAMPDB(sql);
+ }
+
+ //=====================================================================
+ void TimestampDatabaseHandler::RemoveNode(const std::string& searchAtt, tree::Node* node)
+ {
+ int n=node->GetNumberOfChildren();
+ if(n>0)
+ {
+ std::vector<tree::Node*> children=node->GetChildrenList();
+ std::vector<tree::Node*>::iterator it;
+ for(it=children.begin();it!=children.end();++it)
+ {
+ RemoveNode(searchAtt,(*it));
+ }
+ }
+ else if(node->GetLevel()==3)
+ {
+ RemoveFile(searchAtt,node->GetAttribute("FullFileName"));
+ }
+
+
+ }
+ //=====================================================================
+ void TimestampDatabaseHandler::RemoveFile(const std::string& searchAtt, const std::string& searchVal)
+ {
+
+ std::stringstream result;
+ std::string sel="SELECT PARENT_ID FROM FILES WHERE "+searchAtt+"='"+searchVal+"'";
+
+ CppSQLite3Query q;
+ QUERYTIMESTAMPDB(sel,q);
+
+ while (!q.eof())
+ {
+ for (int fld = 0; fld < q.numFields(); fld++)
+ {
+ result<<q.getStringField(fld);
+ }
+ q.nextRow();
+ }
+ DBRemove(searchAtt,searchVal);
+
+ int nChildren=0;
+ sel="SELECT ID FROM FILES WHERE PARENT_ID='"+result.str()+"'";
+ CppSQLite3Query q2;
+ QUERYTIMESTAMPDB(sel,q2);
+ while (!q2.eof())
+ {
+ nChildren++;
+ q2.nextRow();
+ }
+ if(nChildren<1)
+ {
+ if(!result.str().compare("0"))
+ {
+ RemoveFile("ID",result.str());
+ }
+ else
+ {
+ DBRemove("ID",result.str());
+ }
+ }
+ }
+
+ //=====================================================================
+ void TimestampDatabaseHandler::DBRemove(const std::string& searchAtt, const std::string& searchVal)
+ {
+
+ std::string query = "DELETE FROM FILES WHERE "+searchAtt+"='"+ searchVal + "';";
+ UPDATETIMESTAMPDB(query);
+ }
+
+ //=====================================================================
+ bool TimestampDatabaseHandler::CheckTimestamp(const std::string pathId, const time_t lastModif)
+ {
+ std::string sel="SELECT LastModified FROM FILES WHERE ID='"+pathId+"';";
+ CppSQLite3Query q;
+ QUERYTIMESTAMPDB(sel,q);
+ double timestamp;
+
+ while (!q.eof())
+ {
+ for (int fld = 0; fld < q.numFields(); fld++)
+ {
+ timestamp=q.getFloatField(fld);
+ }
+ q.nextRow();
+ }
+
+
+ std::stringstream lm;
+ lm<<lastModif;
+ double modif=atof((lm.str()).c_str());
+ if(timestamp<modif)
+ {
+ SetAttribute("LastModified",lm.str(),"ID",pathId);
+ return true;
+ }
+ return false;
+ }
+
+}// namespace creaImageIO
\ No newline at end of file
--- /dev/null
+#ifndef __creaImageIOTimestampDatabaseHandler_h_INCLUDED__
+#define __creaImageIOTimestampDatabaseHandler_h_INCLUDED__
+#include <vector>
+#include <map>
+#include <creaImageIOTree.h>
+class CppSQLite3DB;
+
+namespace creaImageIO
+{
+ using namespace std;
+//=======================================================================
+ /// Concrete TreeHandler which manages a Tree stored in a sqlite database
+ class TimestampDatabaseHandler
+ {
+ public:
+ //====================================================================
+ /// Ctor with database file name
+ TimestampDatabaseHandler(const std::string& filename);
+ /// Dtor
+ virtual ~TimestampDatabaseHandler();
+ //====================================================================
+
+ //====================================================================
+ /// Returns the sqlite db file name
+ const std::string& GetFileName() const { return mFileName; }
+ //====================================================================
+
+ //====================================================================
+ // INITIALIZATION / FINALIZATION
+ //====================================================================
+
+ //====================================================================
+ /// Opens an existing 'source'
+ bool Open();
+ /// Closes the 'source'
+ bool Close();
+ /// Creates a new 'source'
+ bool Create();
+ /// Destroys the 'source'
+ bool Destroy();
+ //====================================================================
+
+ //====================================================================
+ // READ / WRITE
+ //====================================================================
+ //====================================================================
+ ///Returns the id of the path if it's indexed, blank otherwise
+ std::string IsIndexed(const std::string& path);
+ ///Sets the current path's parent
+ bool AddDirectory(const std::string& parent,
+ const std::string& path,
+ const time_t lastModif,
+ const time_t lastRead);
+ ///Adds a new file to the database without a parent
+ void AddFile(const std::string& path, const time_t lastModif, const time_t lastRead);
+ ///Adds a new file to the database with a parent
+ void AddFile(const std::string& parentId,const std::string& path, const time_t lastModif, const time_t lastRead);
+ ///Sets the attribute to the value passed as parameter where the searchParameter is searchValue
+ void SetAttribute(const std::string& attName,
+ const std::string& attValue,
+ const std::string& searchParam,
+ const std::string& searchValue);
+ ///Removes the given node
+ void RemoveNode(const std::string& searchAtt, tree::Node* node);
+ ///Removes the filename with the given pathname
+ void RemoveFile(const std::string& searchAtt, const std::string& searchVal);
+ ///Cleans the path name
+ void CleanName(std::string& str) const;
+ ///Checks the timestamp in the database and compares it with the given one.
+ //If there is a difference, it will return false, otherwise it will return true.
+ bool CheckTimestamp(const std::string pathId, const time_t lastModif);
+
+ //====================================================================
+
+
+ protected:
+ //======================================================================
+ /// Open the database
+ bool DBOpen();
+ //======================================================================
+ //======================================================================
+ // Creation
+ /// Creates a new database on disk and the tables
+ bool DBCreate();
+ //======================================================================
+ //======================================================================
+ // Removes a file from the database
+ void DBRemove(const std::string& searchAtt, const std::string& searchVal);
+
+ private:
+ /// The DB
+ CppSQLite3DB* mDB;
+ /// The physical location associated to the DicomDatabase (directory, db file...)
+ std::string mFileName;
+
+ };
+ // EO class
+ //=======================================================================
+
+
+} // EO namespace creaImageIO
+
+// EOF
+#endif
+
#include <creaImageIOTreeHandlerImageAdder.h>
#include <creaImageIOSystem.h>
#include "boost/filesystem.hpp"
+#include <boost/filesystem/operations.hpp>
+#include <boost/utility.hpp>
+
namespace fs = boost::filesystem;
+using boost::filesystem::path;
+using boost::next;
+using boost::prior;
+
//using namespace crea;
mProgress.IncNumberScannedDirs();
if ( !fs::exists( dirpath ) ) return;
-
+ time_t lastModif=fs::last_write_time(dirpath);
+
fs::directory_iterator end_itr; // default construction yields past-the-end
for ( fs::directory_iterator itr( dirpath );
itr != end_itr;
// If is directory & recurse : do recurse
if ( fs::is_directory(itr->status()) )
{
- if (recursive) AddDirectoryRecursor( itr->string(), recursive);
+ if (recursive)
+ {
+ AddDirectoryRecursor( itr->string(), recursive);
+ }
}
else
{
- mProgress.IncNumberScannedFiles();
- if (IsHandledFile(itr->string()))
- {
- mProgress.IncNumberHandledFiles();
- AddFile( itr->string() );
- }
- mProgressSignal(mProgress);
- if (mProgress.GetStop())
- {
- //itr = end_itr;
- break;
- }
+ bool valid=mTimestampHandler->AddDirectory(dirpath, itr->string(), lastModif, time(0));
+ if(valid)
+ {
+ mProgress.IncNumberScannedFiles();
+ if (IsHandledFile(itr->string()))
+ {
+ mProgress.IncNumberHandledFiles();
+ AddFile( itr->string() );
+ }
+ mProgressSignal(mProgress);
+ if (mProgress.GetStop())
+ {
+ //itr = end_itr;
+ break;
+ }
+ }
}
}
+
}
//=======================================================================
#define __creaImageIOTreeHandlerImageAdder_h_INCLUDED__
#include <creaImageIOTreeHandler.h>
+#include <creaImageIOTimestampDatabaseHandler.h>
#include <creaImageIOImageReader.h>
#include <wx/wx.h>
#include <wx/progdlg.h>
~TreeHandlerImageAdder();
/// Sets the TreeHandler
void SetTreeHandler(TreeHandler* tree) { mTreeHandler = tree;}
+ /// Sets the TimestampDatabaseHandler
+ void SetTimestampHandler(TimestampDatabaseHandler* tdh) { mTimestampHandler = tdh;}
//====================================================================
//====================================================================
bool recurse );
TreeHandler* mTreeHandler;
+ TimestampDatabaseHandler* mTimestampHandler;
ImageReader mReader;
Progress mProgress;
namespace creaImageIO
{
// CTor
- TreeView::TreeView(TreeHandler* handler, GimmickView* gimmick )
+ TreeView::TreeView(TreeHandler* handler, TimestampDatabaseHandler* tdh, GimmickView* gimmick )
: mTreeHandler(handler),
+ mTimestampDatabaseHandler (tdh),
mGimmickView(gimmick)
{
GimmickDebugMessage(1,"TreeView::TreeView"
#define __creaImageIOTreeView_h_INCLUDED__
#include <creaImageIOTreeHandler.h>
+#include <creaImageIOTimestampDatabaseHandler.h>
#include <creaImageIOSystem.h>
#include <vtkImageData.h>
{
public:
/// Ctor
- TreeView(TreeHandler*,GimmickView*);
+ TreeView(TreeHandler*,TimestampDatabaseHandler*,GimmickView*);
/// Virtual destructor
virtual ~TreeView();
protected:
TreeHandler* GetTreeHandler() { return mTreeHandler; }
+ TimestampDatabaseHandler* GetTimestampDatabaseHandler() { return mTimestampDatabaseHandler; }
GimmickView* GetGimmickView() { return mGimmickView; }
private:
/// The TreeHandler with which it corresponds
TreeHandler* mTreeHandler;
+ /// The Timestamp handler with which it corresponds
+ TimestampDatabaseHandler* mTimestampDatabaseHandler;
/// The GimmickView which holds the TreeView
GimmickView* mGimmickView;
//======================================================================
/// Create the tree view for TreeHandler provided
- void WxGimmickView::CreateTreeView( TreeHandler* h)
+ void WxGimmickView::CreateTreeView( TreeHandler* h, TimestampDatabaseHandler* tdh)
{
std::string name(h->GetTree().GetAttribute("Name"));
GimmickMessage(2,"Creating the tree view for '"<<
name<<"'"<<std::endl);
// Create the WxTreeView
- WxTreeView* view = new WxTreeView(h,this,mNotebook,-1);
+ WxTreeView* view = new WxTreeView(h,tdh,this,mNotebook,-1);
// TO DO : TEST THAT A VIEW WITH SAME NAME IS NOT
// ALREADY IN THE MAP
/// Create the tree view for TreeHandler provided
/// (overloaded from GimmickView)
- void CreateTreeView( TreeHandler* );
+ void CreateTreeView( TreeHandler*, TimestampDatabaseHandler* );
private:
#include <wx/gdicmn.h>
#include <boost/date_time/gregorian/gregorian.hpp>
-
const std::string empty_string("");
//=====================================================================
//=====================================================================
// CTor
WxTreeView::WxTreeView(TreeHandler* handler,
+ TimestampDatabaseHandler* tdh,
GimmickView* gimmick,
wxWindow* parent,
const wxWindowID id)
: wxPanel(parent,id),
- TreeView(handler,gimmick)
+ TreeView(handler, tdh, gimmick)
{
GimmickDebugMessage(1,"WxTreeView::WxTreeView"
<<std::endl);
{
needRefresh=true;
}
+ GetTimestampDatabaseHandler()->RemoveNode("PATH",(*i));
GetTreeHandler()->Remove(*i);
}
}
- //=====================================================================
-
-
//=====================================================================
/// Updates a level of the view (adds or removes children, etc.)
void WxTreeView::UpdateLevel( int level )
{
public:
/// Ctor
- WxTreeView(TreeHandler*, GimmickView*,
+ WxTreeView(TreeHandler*, TimestampDatabaseHandler*, GimmickView*,
wxWindow* parent, const wxWindowID id);
/// Virtual destructor
virtual ~WxTreeView();
///Removes selected nodes on given level
virtual void RemoveSelected();
-
+
/// Callback for item selection
void OnItemSelected(wxListEvent& event);