Salome HOME
0c57ace2e93ba183939dda374aaa6b6c6368a7e0
[modules/kernel.git] / src / TOOLSDS / SALOMEDS_Tool.hxx
1 // Copyright (C) 2005  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
3 // 
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either 
7 // version 2.1 of the License.
8 // 
9 // This library is distributed in the hope that it will be useful 
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
12 // Lesser General Public License for more details.
13 //
14 // You should have received a copy of the GNU Lesser General Public  
15 // License along with this library; if not, write to the Free Software 
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
17 //
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 //
20 //  File      : SALOMEDS_Tool.hxx
21 //  Created   : Mon Oct 21 16:24:50 2002
22 //  Author    : Sergey RUIN
23
24 //  Project   : SALOME
25 //  Module    : SALOMEDS
26
27 #ifndef __SALOMEDS_Tool_H__
28 #define __SALOMEDS_Tool_H__
29
30 #include <string>
31 #include <list> 
32
33
34 // IDL headers
35 #include "SALOMEconfig.h"
36 #include CORBA_SERVER_HEADER(SALOMEDS)
37
38 #ifdef WNT
39  #if defined TOOLSDS_EXPORTS
40   #if defined WIN32
41    #define TOOLSDS_EXPORT __declspec( dllexport )
42   #else
43    #define TOOLSDS_EXPORT
44   #endif
45  #else
46   #if defined WIN32
47    #define TOOLSDS_EXPORT __declspec( dllimport )
48   #else
49    #define TOOLSDS_EXPORT
50   #endif
51  #endif
52 #else
53  #define TOOLSDS_EXPORT
54 #endif
55
56 class TOOLSDS_EXPORT SALOMEDS_Tool                                
57 {
58 public:
59  
60   // Returns the unique temporary directory, that is defined in SALOME_TMP_DIR if this variable is set
61   // otherwise return /tmp/something/ for Unix or c:\something\ for WNT
62   static std::string GetTmpDir();
63
64  
65   // Removes files which are in <theDirectory>, the files for deletion are listed in <theFiles>
66   // if <IsDirDeleted> is true <theDirectory> is also deleted if it is empty
67   static void RemoveTemporaryFiles(const std::string& theDirectory,
68                                    const SALOMEDS::ListOfFileNames& theFiles,
69                                    const bool IsDirDeleted);
70
71   // Converts files listed in <theFiles> which are in <theFromDirectory> into a byte sequence TMPFile
72   static SALOMEDS::TMPFile* PutFilesToStream(const std::string& theFromDirectory, 
73                                              const SALOMEDS::ListOfFileNames& theFiles,
74                                              const int theNamesOnly = 0);
75
76   // Converts files listed in <theFiles> which will be named as pointed in the <theFileNames> into a byte sequence TMPFile
77   static SALOMEDS::TMPFile* PutFilesToStream(const SALOMEDS::ListOfFileNames& theFiles,
78                                              const SALOMEDS::ListOfFileNames& theFileNames);
79
80   // Converts a byte sequence <theStream> to files and places them in <theToDirectory>
81   static SALOMEDS::ListOfFileNames_var PutStreamToFiles(const SALOMEDS::TMPFile& theStream,
82                                                         const std::string& theToDirectory,
83                                                         const int theNamesOnly = 0);
84
85   // Returns the name by the path
86   // for an example: if thePath = "/tmp/aaa/doc1.hdf" the function returns "doc1"
87   static std::string GetNameFromPath(const std::string& thePath);
88
89   // Returns the directory by the path
90   // for an example: if thePath = "/tmp/aaa/doc1.hdf" the function returns "/tmp/aaa"
91   static std::string GetDirFromPath(const std::string& thePath);
92
93   // Retrieves specified flaf from "AttributeFlags" attribute
94   static bool GetFlag( const int             theFlag,
95                        SALOMEDS::Study_var   theStudy,
96                        SALOMEDS::SObject_var theObj );
97
98   // Sets/Unsets specified flaf from "AttributeFlags" attribute
99   static bool SetFlag( const int           theFlag,
100                        SALOMEDS::Study_var theStudy,
101                        const std::string&  theEntry,
102                        const bool          theValue );
103
104   // Get all children of object. If theObj is null all objects of study are returned
105   static void GetAllChildren( SALOMEDS::Study_var               theStudy,
106                               SALOMEDS::SObject_var             theObj,
107                               std::list<SALOMEDS::SObject_var>& theList );
108
109 };
110 #endif
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130