Salome HOME
PR: merge from branch BR_UnitTests tag mergeto_trunk_17oct05
[modules/kernel.git] / src / TOOLSDS / SALOMEDS_Tool.hxx
1 //  File      : SALOMEDS_Tool.hxx
2 //  Created   : Mon Oct 21 16:24:50 2002
3 //  Author    : Sergey RUIN
4
5 //  Project   : SALOME
6 //  Module    : SALOMEDS
7 //  Copyright : Open CASCADE
8
9
10 #ifndef __SALOMEDS_Tool_H__
11 #define __SALOMEDS_Tool_H__
12
13 #include <string>
14 #include <list> 
15
16
17 // IDL headers
18 #include "SALOMEconfig.h"
19 #include CORBA_SERVER_HEADER(SALOMEDS)
20
21 #ifdef WNT
22 #include <SALOME_WNT.hxx>
23 #else
24 #define SALOME_WNT_EXPORT
25 #endif
26
27 class SALOME_WNT_EXPORT SALOMEDS_Tool                                
28 {
29
30 public:
31  
32   // Returns the unique temporary directory, that is defined in SALOME_TMP_DIR if this variable is set
33   // otherwise return /tmp/something/ for Unix or c:\something\ for WNT
34   static std::string GetTmpDir();
35
36  
37   // Removes files which are in <theDirectory>, the files for deletion are listed in <theFiles>
38   // if <IsDirDeleted> is true <theDirectory> is also deleted if it is empty
39   static void RemoveTemporaryFiles(const std::string& theDirectory,
40                                    const SALOMEDS::ListOfFileNames& theFiles,
41                                    const bool IsDirDeleted);
42
43   // Converts files listed in <theFiles> which are in <theFromDirectory> into a byte sequence TMPFile
44   static SALOMEDS::TMPFile* PutFilesToStream(const std::string& theFromDirectory, 
45                                              const SALOMEDS::ListOfFileNames& theFiles,
46                                              const int theNamesOnly = 0);
47
48   // Converts a byte sequence <theStream> to files and places them in <theToDirectory>
49   static SALOMEDS::ListOfFileNames_var PutStreamToFiles(const SALOMEDS::TMPFile& theStream,
50                                                         const std::string& theToDirectory,
51                                                         const int theNamesOnly = 0);
52
53   // Returns the name by the path
54   // for an example: if thePath = "/tmp/aaa/doc1.hdf" the function returns "doc1"
55   static std::string GetNameFromPath(const std::string& thePath);
56
57   // Returns the directory by the path
58   // for an example: if thePath = "/tmp/aaa/doc1.hdf" the function returns "/tmp/aaa"
59   static std::string GetDirFromPath(const std::string& thePath);
60
61   // Retrieves specified flaf from "AttributeFlags" attribute
62   static bool GetFlag( const int             theFlag,
63                        SALOMEDS::Study_var   theStudy,
64                        SALOMEDS::SObject_var theObj );
65
66   // Sets/Unsets specified flaf from "AttributeFlags" attribute
67   static bool SetFlag( const int           theFlag,
68                        SALOMEDS::Study_var theStudy,
69                        const std::string&  theEntry,
70                        const bool          theValue );
71
72   // Get all children of object. If theObj is null all objects of study are returned
73   static void GetAllChildren( SALOMEDS::Study_var               theStudy,
74                               SALOMEDS::SObject_var             theObj,
75                               std::list<SALOMEDS::SObject_var>& theList );
76
77 };
78 #endif
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98