Salome HOME
Join modifications from branch BR_DEBUG_3_2_0b1
[modules/gui.git] / src / LightApp / LightApp_Driver.h
1 // Copyright (C) 2005  OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
2 // 
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either 
6 // version 2.1 of the License.
7 // 
8 // This library is distributed in the hope that it will be useful 
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of 
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public  
14 // License along with this library; if not, write to the Free Software 
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 #ifndef LIGHTAPP_DRIVER_H
20 #define LIGHTAPP_DRIVER_H
21
22 #include <LightApp.h>
23
24 #include "string"
25 #include "vector"
26 #include "map"
27
28 #ifdef WIN32
29 #pragma warning( disable:4251 )
30 #endif
31
32 /*!Description : Driver can save to file and read from file list of files for light modules*/
33
34 class LIGHTAPP_EXPORT LightApp_Driver
35 {
36 public:
37   LightApp_Driver();
38   virtual ~LightApp_Driver();
39
40
41   typedef std::vector<std::string> ListOfFiles;
42
43   virtual bool        SaveDatasInFile   (const char* theFileName, bool isMultiFile);
44   virtual bool        ReadDatasFromFile (const char* theFileName, bool isMultiFile);
45   virtual std::string GetTmpDir      (const char* theURL, const bool isMultiFile);
46
47   ListOfFiles         GetListOfFiles (const char* theModuleName);
48   virtual void        SetListOfFiles (const char* theModuleName, const ListOfFiles theListOfFiles);
49   virtual void        RemoveTemporaryFiles(const char* theModuleName, const bool IsDirDeleted);
50   void                RemoveFiles( const ListOfFiles& theFiles, const bool IsDirDeleted);
51
52   virtual void        ClearDriverContents();
53
54 protected:
55   void                PutFilesToStream(const std::string& theModuleName, unsigned char*& theBuffer,
56                                        long& theBufferSize, bool theNamesOnly = false);
57   ListOfFiles         PutStreamToFiles(const unsigned char* theBuffer,
58                                        const long theBufferSize, bool theNamesOnly = false);
59
60   std::string GetTmpDir();
61   std::string GetDirFromPath(const std::string& thePath);
62
63   void                SetIsTemporary( bool theFlag ) { myIsTemp = theFlag; }
64   bool                IsTemporary() const { return myIsTemp; }
65
66 protected:
67   typedef std::map<std::string, ListOfFiles> MapOfListOfFiles;
68   MapOfListOfFiles                           myMap;
69   std::string                                myTmpDir;
70
71 private:
72   bool                                       myIsTemp;
73 };
74
75 #endif