1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // File : SALOMEDS_Tool.hxx
23 // Created : Mon Oct 21 16:24:50 2002
24 // Author : Sergey RUIN
28 #ifndef __SALOMEDS_Tool_H__
29 #define __SALOMEDS_Tool_H__
36 #include "SALOMEconfig.h"
37 #include CORBA_SERVER_HEADER(SALOMEDS)
40 # if defined TOOLSDS_EXPORTS
41 # define TOOLSDS_EXPORT __declspec( dllexport )
43 # define TOOLSDS_EXPORT __declspec( dllimport )
46 # define TOOLSDS_EXPORT
49 class TOOLSDS_EXPORT SALOMEDS_Tool
53 // Returns the unique temporary directory, that is defined in SALOME_TMP_DIR if this variable is set
54 // otherwise return /tmp/something/ for Unix or c:\something\ for WIN32
55 static std::string GetTmpDir();
58 // Removes files which are in <theDirectory>, the files for deletion are listed in <theFiles>
59 // if <IsDirDeleted> is true <theDirectory> is also deleted if it is empty
60 static void RemoveTemporaryFiles(const std::string& theDirectory,
61 const SALOMEDS::ListOfFileNames& theFiles,
62 const bool IsDirDeleted);
64 // Converts files listed in <theFiles> which are in <theFromDirectory> into a byte sequence TMPFile
65 static SALOMEDS::TMPFile* PutFilesToStream(const std::string& theFromDirectory,
66 const SALOMEDS::ListOfFileNames& theFiles,
67 const int theNamesOnly = 0);
69 // Converts files listed in <theFiles> which will be named as pointed in the <theFileNames> into a byte sequence TMPFile
70 static SALOMEDS::TMPFile* PutFilesToStream(const SALOMEDS::ListOfFileNames& theFiles,
71 const SALOMEDS::ListOfFileNames& theFileNames);
73 // Converts a byte sequence <theStream> to files and places them in <theToDirectory>
74 static SALOMEDS::ListOfFileNames_var PutStreamToFiles(const SALOMEDS::TMPFile& theStream,
75 const std::string& theToDirectory,
76 const int theNamesOnly = 0);
78 // Returns the name by the path
79 // for an example: if thePath = "/tmp/aaa/doc1.hdf" the function returns "doc1"
80 static std::string GetNameFromPath(const std::string& thePath);
82 // Returns the directory by the path
83 // for an example: if thePath = "/tmp/aaa/doc1.hdf" the function returns "/tmp/aaa"
84 static std::string GetDirFromPath(const std::string& thePath);
86 // Retrieves specified flaf from "AttributeFlags" attribute
87 static bool GetFlag( const int theFlag,
88 SALOMEDS::Study_var theStudy,
89 SALOMEDS::SObject_var theObj );
91 // Sets/Unsets specified flaf from "AttributeFlags" attribute
92 static bool SetFlag( const int theFlag,
93 SALOMEDS::Study_var theStudy,
94 const std::string& theEntry,
95 const bool theValue );
97 // Get all children of object. If theObj is null all objects of study are returned
98 static void GetAllChildren( SALOMEDS::Study_var theStudy,
99 SALOMEDS::SObject_var theObj,
100 std::list<SALOMEDS::SObject_var>& theList );