Salome HOME
Copyrights update
[modules/yacs.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/
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 //  Copyright : Open CASCADE
27
28
29 #ifndef __SALOMEDS_Tool_H__
30 #define __SALOMEDS_Tool_H__
31
32 #include <string>
33 #include <list> 
34
35
36 // IDL headers
37 #include "SALOMEconfig.h"
38 #include CORBA_SERVER_HEADER(SALOMEDS)
39
40 #ifdef WNT
41 #include <SALOME_WNT.hxx>
42 #else
43 #define SALOME_WNT_EXPORT
44 #endif
45
46 class SALOME_WNT_EXPORT SALOMEDS_Tool                                
47 {
48
49 public:
50  
51   // Returns the unique temporary directory, that is defined in SALOME_TMP_DIR if this variable is set
52   // otherwise return /tmp/something/ for Unix or c:\something\ for WNT
53   static std::string GetTmpDir();
54
55  
56   // Removes files which are in <theDirectory>, the files for deletion are listed in <theFiles>
57   // if <IsDirDeleted> is true <theDirectory> is also deleted if it is empty
58   static void RemoveTemporaryFiles(const std::string& theDirectory,
59                                    const SALOMEDS::ListOfFileNames& theFiles,
60                                    const bool IsDirDeleted);
61
62   // Converts files listed in <theFiles> which are in <theFromDirectory> into a byte sequence TMPFile
63   static SALOMEDS::TMPFile* PutFilesToStream(const std::string& theFromDirectory, 
64                                              const SALOMEDS::ListOfFileNames& theFiles,
65                                              const int theNamesOnly = 0);
66
67   // Converts a byte sequence <theStream> to files and places them in <theToDirectory>
68   static SALOMEDS::ListOfFileNames_var PutStreamToFiles(const SALOMEDS::TMPFile& theStream,
69                                                         const std::string& theToDirectory,
70                                                         const int theNamesOnly = 0);
71
72   // Returns the name by the path
73   // for an example: if thePath = "/tmp/aaa/doc1.hdf" the function returns "doc1"
74   static std::string GetNameFromPath(const std::string& thePath);
75
76   // Returns the directory by the path
77   // for an example: if thePath = "/tmp/aaa/doc1.hdf" the function returns "/tmp/aaa"
78   static std::string GetDirFromPath(const std::string& thePath);
79
80   // Retrieves specified flaf from "AttributeFlags" attribute
81   static bool GetFlag( const int             theFlag,
82                        SALOMEDS::Study_var   theStudy,
83                        SALOMEDS::SObject_var theObj );
84
85   // Sets/Unsets specified flaf from "AttributeFlags" attribute
86   static bool SetFlag( const int           theFlag,
87                        SALOMEDS::Study_var theStudy,
88                        const std::string&  theEntry,
89                        const bool          theValue );
90
91   // Get all children of object. If theObj is null all objects of study are returned
92   static void GetAllChildren( SALOMEDS::Study_var               theStudy,
93                               SALOMEDS::SObject_var             theObj,
94                               std::list<SALOMEDS::SObject_var>& theList );
95
96 };
97 #endif
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117