Back to index

salome-kernel  6.5.0
SALOMEDS_Tool.hxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 //  File      : SALOMEDS_Tool.hxx
00024 //  Created   : Mon Oct 21 16:24:50 2002
00025 //  Author    : Sergey RUIN
00026 //  Project   : SALOME
00027 //  Module    : SALOMEDS
00028 //
00029 #ifndef __SALOMEDS_Tool_H__
00030 #define __SALOMEDS_Tool_H__
00031 
00032 #include <string>
00033 #include <list> 
00034 
00035 
00036 // IDL headers
00037 #include "SALOMEconfig.h"
00038 #include CORBA_SERVER_HEADER(SALOMEDS)
00039 
00040 #ifdef WIN32
00041 # if defined TOOLSDS_EXPORTS
00042 #  define TOOLSDS_EXPORT __declspec( dllexport )
00043 # else
00044 #  define TOOLSDS_EXPORT __declspec( dllimport )
00045 # endif
00046 #else
00047 # define TOOLSDS_EXPORT
00048 #endif
00049 
00050 class TOOLSDS_EXPORT SALOMEDS_Tool                                
00051 {
00052 public:
00053  
00054   // Returns the unique temporary directory, that is defined in SALOME_TMP_DIR if this variable is set
00055   // otherwise return /tmp/something/ for Unix or c:\something\ for WIN32
00056   static std::string GetTmpDir();
00057 
00058  
00059   // Removes files which are in <theDirectory>, the files for deletion are listed in <theFiles>
00060   // if <IsDirDeleted> is true <theDirectory> is also deleted if it is empty
00061   static void RemoveTemporaryFiles(const std::string& theDirectory,
00062                                    const SALOMEDS::ListOfFileNames& theFiles,
00063                                    const bool IsDirDeleted);
00064 
00065   // Converts files listed in <theFiles> which are in <theFromDirectory> into a byte sequence TMPFile
00066   static SALOMEDS::TMPFile* PutFilesToStream(const std::string& theFromDirectory, 
00067                                              const SALOMEDS::ListOfFileNames& theFiles,
00068                                              const int theNamesOnly = 0);
00069 
00070   // Converts files listed in <theFiles> which will be named as pointed in the <theFileNames> into a byte sequence TMPFile
00071   static SALOMEDS::TMPFile* PutFilesToStream(const SALOMEDS::ListOfFileNames& theFiles,
00072                                              const SALOMEDS::ListOfFileNames& theFileNames);
00073 
00074   // Converts a byte sequence <theStream> to files and places them in <theToDirectory>
00075   static SALOMEDS::ListOfFileNames_var PutStreamToFiles(const SALOMEDS::TMPFile& theStream,
00076                                                         const std::string& theToDirectory,
00077                                                         const int theNamesOnly = 0);
00078 
00079   // Returns the name by the path
00080   // for an example: if thePath = "/tmp/aaa/doc1.hdf" the function returns "doc1"
00081   static std::string GetNameFromPath(const std::string& thePath);
00082 
00083   // Returns the directory by the path
00084   // for an example: if thePath = "/tmp/aaa/doc1.hdf" the function returns "/tmp/aaa"
00085   static std::string GetDirFromPath(const std::string& thePath);
00086 
00087   // Retrieves specified flaf from "AttributeFlags" attribute
00088   static bool GetFlag( const int             theFlag,
00089                        SALOMEDS::Study_var   theStudy,
00090                        SALOMEDS::SObject_var theObj );
00091 
00092   // Sets/Unsets specified flaf from "AttributeFlags" attribute
00093   static bool SetFlag( const int           theFlag,
00094                        SALOMEDS::Study_var theStudy,
00095                        const std::string&  theEntry,
00096                        const bool          theValue );
00097 
00098   // Get all children of object. If theObj is null all objects of study are returned
00099   static void GetAllChildren( SALOMEDS::Study_var               theStudy,
00100                               SALOMEDS::SObject_var             theObj,
00101                               std::list<SALOMEDS::SObject_var>& theList );
00102 
00103 };
00104 #endif
00105 
00106 
00107 
00108 
00109 
00110 
00111 
00112 
00113 
00114 
00115 
00116 
00117 
00118 
00119 
00120 
00121 
00122 
00123 
00124