ALBA
albaStorage.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Program: ALBA (Agile Library for Biomedical Applications)
4 Module: albaStorage
5 Authors: Marco Petrone
6
7 Copyright (c) BIC
8 All rights reserved. See Copyright.txt or
9
10
11 This software is distributed WITHOUT ANY WARRANTY; without even
12 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
13 PURPOSE. See the above copyright notice for more information.
14
15=========================================================================*/
16#ifndef __albaStorage_h__
17#define __albaStorage_h__
18
19#include "albaObject.h"
20#include "albaString.h"
21#include <set>
22
23//----------------------------------------------------------------------------
24// forward declarations :
25//----------------------------------------------------------------------------
27class albaStorable;
28class albaObserver;
29
47class ALBA_EXPORT albaStorage: public albaObject
48{
49public:
51
52 enum STORAGE_IO_ERRORS {IO_OK=0,IO_GENERIC_ERROR,IO_WRONG_OBJECT_TYPE,IO_LAST_ERROR};
53
55 virtual ~albaStorage() {}
56
58 virtual void SetURL(const char *name);
59
62
64 const char *GetURL();
65
69 const char *GetPareserURL();
70
72 int Store();
73
75 int Restore();
76
79
82
84 virtual int ResolveInputURL(const char * url, albaString &filename, albaObserver *observer = NULL)=0;
85
87 //virtual bool ResolveOutputURL(const albaCString url, albaString &filename)=0;
88
92 virtual int StoreToURL(const char *filename, const char *url=NULL) = 0;
93
98 virtual int ReleaseURL(const char *url) = 0;
99
103 virtual void GetTmpFile(albaString &filename);
104
106 void ReleaseTmpFile(const char *filename);
107
111 bool IsFileInDirectory(const char *filename);
112
117 virtual void SetTmpFolder(const char *folder) {m_TmpFolder=folder;}
118
120 virtual const char* GetTmpFolder() {return m_TmpFolder;}
121
122 void SetErrorCode(int err) {m_ErrorCode=err;}
123 int GetErrorCode() {return m_ErrorCode;}
124
125 bool NeedsUpgrade() {return m_NeedsUpgrade;};
126
127protected:
129 virtual int InternalStore()=0;
130
132 virtual int InternalRestore()=0;
133
135 virtual int OpenDirectory(const char *dir_name)=0;
136
140
145
146 std::set<albaString> m_TmpFileNames;
147 std::set<albaString> m_FilesDictionary;
149};
150#endif // _albaStorage_h_
long albaID
type for IDs inside ALBA
Definition: albaDefines.h:58
Abstract superclass for all ALBA classes implementing RTTI APIs.
Definition: albaObject.h:38
Interface implementing the Observer of the Subject/Observer design pattern.
Definition: albaObserver.h:36
albaStorable is an interface for serializable objects.
Definition: albaStorable.h:41
Abstract class representing the interface for the unit of information stored in the storage.
Abstract class for an abject mastering the storing/restoring of objects This is an abstract class pro...
Definition: albaStorage.h:48
int GetErrorCode()
Definition: albaStorage.h:123
albaStorageElement * m_DocumentElement
document stored element
Definition: albaStorage.h:139
void ForceParserURL()
Force Copy storage URL to parser URL (used by the ALBA1.x importer)
virtual void GetTmpFile(albaString &filename)
Return a name of file to be used as tmp file during store/restore.
virtual int ReleaseURL(const char *url)=0
Remove a file from the specified URL.
virtual int InternalStore()=0
This is called by Store() and must be reimplemented by subclasses.
albaStorable * GetDocument()
return the document object restored
virtual int StoreToURL(const char *filename, const char *url=NULL)=0
resolve an URL and provide a local filename to be used as output
virtual int OpenDirectory(const char *dir_name)=0
populate the list of files in the storage folder
virtual ~albaStorage()
Definition: albaStorage.h:55
const char * GetPareserURL()
Return the name of the last read file, this is internally used when writing to a new file to read and...
std::set< albaString > m_FilesDictionary
list of files in the storage folder: to be populated by OpenDirectory()
Definition: albaStorage.h:147
albaString m_TmpFolder
folder where to store tmp files
Definition: albaStorage.h:144
const char * GetURL()
Return the URL of the document to be read or written.
albaStorable * m_Document
document object to be stored, or being restored
Definition: albaStorage.h:138
int Store()
perform storing.
void SetDocument(albaStorable *doc)
set the document element to be stored
virtual int ResolveInputURL(const char *url, albaString &filename, albaObserver *observer=NULL)=0
resolve an URL and provide local filename to be used as input
bool IsFileInDirectory(const char *filename)
Check if a file is present in the storage directory.
albaID m_TmpFileId
counter for unique tmp file naming
Definition: albaStorage.h:143
std::set< albaString > m_TmpFileNames
name of tmp files in the MSF dir
Definition: albaStorage.h:146
virtual void SetURL(const char *name)
Set the URL of the document to be read or written.
virtual void SetTmpFolder(const char *folder)
Set the folder where to store tmp files.
Definition: albaStorage.h:117
int m_ErrorCode
the error code 0==OK
Definition: albaStorage.h:148
virtual const char * GetTmpFolder()
return the folder where tmp files are stored
Definition: albaStorage.h:120
albaAbstractTypeMacro(albaStorage, albaObject)
albaString m_URL
name of the file being accessed
Definition: albaStorage.h:141
bool NeedsUpgrade()
Definition: albaStorage.h:125
@ IO_GENERIC_ERROR
Definition: albaStorage.h:52
void ReleaseTmpFile(const char *filename)
remove the tmp file
albaString m_ParserURL
name of the last parsed file (used for SaveAs)
Definition: albaStorage.h:142
virtual int InternalRestore()=0
This is called by Restore() and must be reimplemented by subclasses.
bool m_NeedsUpgrade
Flag used to enable or not the upgrade mechanism.
Definition: albaStorage.h:137
int Restore()
perform restoring.
void SetErrorCode(int err)
Definition: albaStorage.h:122
albaString - performs common string operations on c-strings.
Definition: albaString.h:43