1 // Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 // File : SALOMEDS_Tool.hxx
21 // Created : Mon Oct 21 16:24:50 2002
22 // Author : Sergey RUIN
27 #ifndef __SALOMEDS_Tool_H__
28 #define __SALOMEDS_Tool_H__
35 #include "SALOMEconfig.h"
36 #include CORBA_SERVER_HEADER(SALOMEDS)
39 #include <SALOME_WNT.hxx>
41 #define SALOME_WNT_EXPORT
44 class SALOME_WNT_EXPORT SALOMEDS_Tool
49 // Returns the unique temporary directory, that is defined in SALOME_TMP_DIR if this variable is set
50 // otherwise return /tmp/something/ for Unix or c:\something\ for WNT
51 static std::string GetTmpDir();
54 // Removes files which are in <theDirectory>, the files for deletion are listed in <theFiles>
55 // if <IsDirDeleted> is true <theDirectory> is also deleted if it is empty
56 static void RemoveTemporaryFiles(const std::string& theDirectory,
57 const SALOMEDS::ListOfFileNames& theFiles,
58 const bool IsDirDeleted);
60 // Converts files listed in <theFiles> which are in <theFromDirectory> into a byte sequence TMPFile
61 static SALOMEDS::TMPFile* PutFilesToStream(const std::string& theFromDirectory,
62 const SALOMEDS::ListOfFileNames& theFiles,
63 const int theNamesOnly = 0);
65 // Converts files listed in <theFiles> which will be named as pointed in the <theFileNames> into a byte sequence TMPFile
66 static SALOMEDS::TMPFile* PutFilesToStream(const SALOMEDS::ListOfFileNames& theFiles,
67 const SALOMEDS::ListOfFileNames& theFileNames);
69 // Converts a byte sequence <theStream> to files and places them in <theToDirectory>
70 static SALOMEDS::ListOfFileNames_var PutStreamToFiles(const SALOMEDS::TMPFile& theStream,
71 const std::string& theToDirectory,
72 const int theNamesOnly = 0);
74 // Returns the name by the path
75 // for an example: if thePath = "/tmp/aaa/doc1.hdf" the function returns "doc1"
76 static std::string GetNameFromPath(const std::string& thePath);
78 // Returns the directory by the path
79 // for an example: if thePath = "/tmp/aaa/doc1.hdf" the function returns "/tmp/aaa"
80 static std::string GetDirFromPath(const std::string& thePath);
82 // Retrieves specified flaf from "AttributeFlags" attribute
83 static bool GetFlag( const int theFlag,
84 SALOMEDS::Study_var theStudy,
85 SALOMEDS::SObject_var theObj );
87 // Sets/Unsets specified flaf from "AttributeFlags" attribute
88 static bool SetFlag( const int theFlag,
89 SALOMEDS::Study_var theStudy,
90 const std::string& theEntry,
91 const bool theValue );
93 // Get all children of object. If theObj is null all objects of study are returned
94 static void GetAllChildren( SALOMEDS::Study_var theStudy,
95 SALOMEDS::SObject_var theObj,
96 std::list<SALOMEDS::SObject_var>& theList );