Add a Distributed file to the Salome_file.
\param comp_file_name name of the file with the path.
- \param source_Salome_file Salome_file that managed the distributed version of the file.
\exception raised if the file is already added into the Salome_file.
*/
- void setDistributedFile(in string comp_file_name,
- in Engines::Salome_file source_Salome_file) raises (SALOME::SALOME_Exception);
+ void setDistributedFile(in string comp_file_name) raises (SALOME::SALOME_Exception);
+
+ /*!
+ Connect a Salome_file with another Salome_file.
+ It works only if the Salome_file managed only one file
+
+ \param source_Salome_file Salome_file that managed the distributed version of the file.
+
+ \exception raised if there is more or less than one file.
+ */
+ void connect(in Engines::Salome_file source_Salome_file) raises (SALOME::SALOME_Exception);
+ /*!
+ Connect the managed file file_name to a Salome_file.
+
+ \param file_name name of the file without the path.
+ \param source_Salome_file Salome_file that managed the distributed version of the file.
+
+ \exception raised if the file doesn't exist.
+ */
+ void connectDistributedFile(in string file_name,
+ in Engines::Salome_file source_Salome_file) raises (SALOME::SALOME_Exception);
+
/*!
Connect the file_name with a Distributed file_name.
COMMON_CPPFLAGS=\
@PYTHON_INCLUDES@ \
@MPI_INCLUDES@ \
- @CAS_CPPFLAGS@ @CAS_CXXFLAGS@ \
@QT_MT_INCLUDES@ \
-I$(srcdir)/../Basics \
-I$(srcdir)/../SALOMELocalTrace \
{
}
+//=============================================================================
+/*!
+ * CORBA method
+ * \see Engines::Salome_file::load
+ */
+//=============================================================================
void
Salome_file_i::load(const char* hdf5_file) {
_state.hdf5_file_name = CORBA::string_dup(hdf5_file);
}
}
+//=============================================================================
+/*!
+ * CORBA method
+ * \see Engines::Salome_file::save
+ */
+//=============================================================================
void
Salome_file_i::save(const char* hdf5_file) {
_state.hdf5_file_name = CORBA::string_dup(hdf5_file);
}
}
+//=============================================================================
+/*!
+ * CORBA method
+ * \see Engines::Salome_file::save_all
+ */
+//=============================================================================
void
Salome_file_i::save_all(const char* hdf5_file) {
}
}
+//=============================================================================
+/*!
+ * CORBA method
+ * \see Engines::Salome_file::setLocalFile
+ */
+//=============================================================================
void
Salome_file_i::setLocalFile(const char* comp_file_name)
{
_state.files_ok = false;
}
+//=============================================================================
+/*!
+ * CORBA method
+ * \see Engines::Salome_file::setDistributedFile
+ */
+//=============================================================================
void
-Salome_file_i::setDistributedFile(const char* comp_file_name,
- Engines::Salome_file_ptr source_Salome_file)
+Salome_file_i::setDistributedFile(const char* comp_file_name)
{
std::string file_name("");
std::string path("");
}
// Test if this file is already added
- //_t_fileManaged::iterator it = _fileManaged.find(file_name);
- //if (it != _fileManaged.end())
- //{
- // SALOME::ExceptionStruct es;
- // es.type = SALOME::INTERNAL_ERROR;
- // std::string text = "file already added";
- // es.text = CORBA::string_dup(text.c_str());
- // throw SALOME::SALOME_Exception(es);
- //}
+ _t_fileManaged::iterator it = _fileManaged.find(file_name);
+ if (it != _fileManaged.end())
+ {
+ SALOME::ExceptionStruct es;
+ es.type = SALOME::INTERNAL_ERROR;
+ std::string text = "file already added";
+ es.text = CORBA::string_dup(text.c_str());
+ throw SALOME::SALOME_Exception(es);
+ }
- // Adding file with is informations
+ // Adding file with his informations
Engines::file infos;
infos.file_name = CORBA::string_dup(file_name.c_str());
infos.path = CORBA::string_dup(path.c_str());
infos.status = CORBA::string_dup(status.c_str());
_fileManaged[file_name] = infos;
- _fileDistributedSource[file_name] = Engines::Salome_file::_duplicate(source_Salome_file);
// Update Salome_file state
_state.number_of_files++;
_state.files_ok = false;
}
+//=============================================================================
+/*!
+ * CORBA method
+ * \see Engines::Salome_file::connect
+ */
+//=============================================================================
+void
+Salome_file_i::connect(Engines::Salome_file_ptr source_Salome_file)
+{
+ // We can connect this Salome_file if there is only one file managed
+ // by the Salome_file
+ std::string fname;
+ if (_fileManaged.size() == 1)
+ {
+ // only one file managed
+ _t_fileManaged::iterator it = _fileManaged.begin();
+ fname = it->first;
+ _fileDistributedSource[fname] = Engines::Salome_file::_duplicate(source_Salome_file);
+ }
+ else
+ {
+ SALOME::ExceptionStruct es;
+ es.type = SALOME::INTERNAL_ERROR;
+ std::string text = "cannot connect";
+ es.text = CORBA::string_dup(text.c_str());
+ throw SALOME::SALOME_Exception(es);
+ }
+}
+//=============================================================================
+/*!
+ * CORBA method
+ * \see Engines::Salome_file::connectDistributedFile
+ */
+//=============================================================================
+void
+Salome_file_i::connectDistributedFile(const char * file_name,
+ Engines::Salome_file_ptr source_Salome_file)
+{
+ // Test if this file is added
+ _t_fileManaged::iterator it = _fileManaged.find(file_name);
+ if (it == _fileManaged.end())
+ {
+ SALOME::ExceptionStruct es;
+ es.type = SALOME::INTERNAL_ERROR;
+ std::string text = "file is not added";
+ es.text = CORBA::string_dup(text.c_str());
+ throw SALOME::SALOME_Exception(es);
+ }
+ else
+ {
+ _fileDistributedSource[file_name] = Engines::Salome_file::_duplicate(source_Salome_file);
+ }
+}
+
+//=============================================================================
+/*!
+ * CORBA method
+ * \see Engines::Salome_file::setDistributedSourceFile
+ */
+//=============================================================================
void
Salome_file_i::setDistributedSourceFile(const char* file_name,
const char * source_file_name)
{
std::string fname(file_name);
- // Test if this file is managed
+ // Test if this file is added
_t_fileManaged::iterator it = _fileManaged.find(fname);
if (it == _fileManaged.end())
{
SALOME::ExceptionStruct es;
es.type = SALOME::INTERNAL_ERROR;
- std::string text = "file is not managed";
+ std::string text = "file is not added";
es.text = CORBA::string_dup(text.c_str());
throw SALOME::SALOME_Exception(es);
}
-
- _fileManaged[fname].source_file_name = CORBA::string_dup(source_file_name);
+ else
+ {
+ _fileManaged[fname].source_file_name = CORBA::string_dup(source_file_name);
+ }
}
+//=============================================================================
+/*!
+ * CORBA method
+ * \see Engines::Salome_file::recvFiles
+ */
+//=============================================================================
void
Salome_file_i::recvFiles() {
{
bool result = true;
Engines::file file_infos = begin->second;
+ // Test if the file is local or distributed
if (std::string(file_infos.type.in()) == "local")
{
if (std::string(file_infos.status.in()) == "not_ok")
if (std::string(file_infos.status.in()) == "not_ok")
result = getDistributedFile(file_infos.file_name.in());
}
+ // if the result is false
+ // we add this file to files_not_ok
if (!result)
{
files_not_ok.append(" ");
es.text = CORBA::string_dup(text.c_str());
throw SALOME::SALOME_Exception(es);
}
-
- // We change the state of the Salome_file
- _state.files_ok = true;
+ else
+ {
+ // We change the state of the Salome_file
+ _state.files_ok = true;
+ }
}
+//=============================================================================
+/*!
+ * local C++ method : This method is used by revFiles to check if a local
+ * managed file is ok.
+ * \param fileName name of the file
+ */
+//=============================================================================
bool
Salome_file_i::checkLocalFile(std::string file_name)
{
return result;
}
+//=============================================================================
+/*!
+ * local C++ method : this method is used by recvFiles to get a
+ * distributed file from is distributed source.
+ * If there is no source_file_name for the file, it tries to get
+ * the file from the source. In this case, the source distributed file has to managed
+ * only one file to be able to the send the file.
+ *
+ * \param fileName name of the file
+ */
+//=============================================================================
bool
Salome_file_i::getDistributedFile(std::string file_name)
{
return result;
}
+//=============================================================================
+/*!
+ * CORBA method
+ * \see Engines::Salome_file::removeFile
+ */
+//=============================================================================
void
Salome_file_i::removeFile(const char* file_name)
{
MESSAGE("Salome_file_i::removeFile : NOT YET IMPLEMENTED");
}
+//=============================================================================
+/*!
+ * CORBA method
+ * \see Engines::Salome_file::deleteFile
+ */
+//=============================================================================
void
Salome_file_i::deleteFile(const char* file_name) {
MESSAGE("Salome_file_i::deleteFile : NOT YET IMPLEMENTED");
}
+//=============================================================================
+/*!
+ * CORBA method
+ * \see Engines::Salome_file::removeFiles
+ */
+//=============================================================================
void
Salome_file_i::removeFiles() {
MESSAGE("Salome_file_i::removeFiles : NOT YET IMPLEMENTED");
}
+//=============================================================================
+/*!
+ * CORBA method
+ * \see Engines::Salome_file::deleteFiles
+ */
+//=============================================================================
void
Salome_file_i::deleteFiles() {
MESSAGE("Salome_file_i::deleteFiles : NOT YET IMPLEMENTED");
}
+//=============================================================================
+/*!
+ * CORBA method
+ * \see Engines::Salome_file::recvFiles
+ */
+//=============================================================================
Engines::files*
Salome_file_i::getFilesInfos() {
return infos;
}
+//=============================================================================
+/*!
+ * CORBA method
+ * \see Engines::Salome_file::getFileInfos
+ */
+//=============================================================================
Engines::file*
Salome_file_i::getFileInfos(const char* file_name) {
return infos;
}
+//=============================================================================
+/*!
+ * CORBA method
+ * \see Engines::Salome_file::getSalome_fileState
+ */
+//=============================================================================
Engines::SfState*
Salome_file_i::getSalome_fileState()
{
/*!
* CORBA method: try to open the file given. If the file is readable, return
* a positive integer else return 0;
- * \param fileName path to the file to be transfered
+ * \param fileName file name to be transfered
* \return fileId = positive integer > 0 if open OK.
*/
//=============================================================================
int aKey = 0;
std::string fname(file_name);
+ if (fname == "") {
+ // We enter in the simple case where the user
+ // has not used setDistributedSourceFile.
+ // In this case we try to see if the Salome_file
+ if (_fileManaged.size() == 1)
+ {
+ // only one file managed
+ _t_fileManaged::iterator it = _fileManaged.begin();
+ fname = it->first;
+ }
+ else
+ {
+ // we can't choose the file so :
+ return aKey;
+ }
+ }
+
_t_fileManaged::iterator it = _fileManaged.find(fname);
if (it == _fileManaged.end())
{
return aKey;
}
- std::string comp_file_name(_fileManaged[file_name].path.in());
- comp_file_name.append(_fileManaged[file_name].file_name.in());
+ std::string comp_file_name(_fileManaged[fname].path.in());
+ comp_file_name.append(fname);
MESSAGE("Salome_file_i::open " << comp_file_name);
FILE* fp;
if ((fp = fopen(comp_file_name.c_str(),"rb")) == NULL)
// Adding files
virtual void setLocalFile(const char* comp_file_name);
- virtual void setDistributedFile(const char* comp_file_name,
- Engines::Salome_file_ptr source_Salome_file);
+ virtual void setDistributedFile(const char* comp_file_name);
+
+ // Configure DistributedFile
+ virtual void connect(Engines::Salome_file_ptr source_Salome_file);
+ virtual void connectDistributedFile(const char * file_name,
+ Engines::Salome_file_ptr source_Salome_file);
virtual void setDistributedSourceFile(const char* file_name,
const char * source_file_name);
virtual void deleteFiles();
- // Informations methods
+ // Informations methods:
virtual Engines::files* getFilesInfos();
virtual Engines::file* getFileInfos(const char* file_name);
virtual Engines::SfState* getSalome_fileState();
virtual bool getDistributedFile(std::string file_name);
protected:
+
+ // Contains a relation between a file ID (int) with
+ // a fd descriptor (FILE*) open on the file.
typedef std::map<int, FILE*> _t_fileAccess;
+
+ // Contains the informations of the files managed by the Salome_file.
typedef std::map<std::string, Engines::file> _t_fileManaged;
+
+ // Contains the CORBA reference for each distributed file managed.
typedef std::map<std::string, Engines::Salome_file_var> _t_fileDistributedSource;
int _fileId;
#include <iostream>
#include <fstream>
#include <sstream>
+#include "HDFascii.hxx"
using namespace std;
cerr << "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" << endl;
cerr << "Test of setDistributedFile()" << endl;
- file.setDistributedFile("/tmp/toto_distributed", file2_ref);
- file.setDistributedSourceFile("toto_distributed", "toto_distributed_source");
+ file.setDistributedFile("/tmp/toto_distributed");
+ file.connectDistributedFile("toto_distributed", file2_ref);
+// file.setDistributedSourceFile("toto_distributed", "toto_distributed_source");
infos = file.getFileInfos("toto_distributed");
print_infos(infos);
}
state = file5.getSalome_fileState();
print_state(state);
+
+ // Test of ConvertFromHDFToASCII
+ // and ConvertFromASCIIToHDF
+ cerr << "Test of ConvertFromASCIIToHDF" << endl;
+ HDFascii::ConvertFromASCIIToHDF("/tmp/toto"); // RETURN NULL !
+ cerr << "Test of ConvertFromHDFToASCII" << endl;
+ cerr << HDFascii::ConvertFromHDFToASCII("test2.hdf", false) << endl;
+ cerr << HDFascii::ConvertFromHDFToASCII("test2.hdf", true) << endl;
+
+ cerr << "End of tests" << endl;
}
#include "HDFOI.hxx"
-#include <OSD_Path.hxx>
-#include <OSD_File.hxx>
-#include <OSD_Protection.hxx>
-#include <OSD_Directory.hxx>
-#include <TCollection_AsciiString.hxx>
+//#include <OSD_Path.hxx>
+//#include <OSD_File.hxx>
+//#include <OSD_Protection.hxx>
+//#include <OSD_Directory.hxx>
+//#include <TCollection_AsciiString.hxx>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <stdio.h>
+#include <sys/stat.h>
+#include <dirent.h>
+#include <sstream>
+#include <fstream>
#ifdef WNT
#include <io.h>
char* restoreName(char* name);
void write_float64(FILE* fp, hdf_float64* value);
void read_float64(FILE* fp, hdf_float64* value);
+bool directoryExists(const char* dir);
+bool createDirectory(const char* dir);
+bool is_readable( const std::string & file );
#define MAX_STRING_SIZE 65535
#define MAX_ID_SIZE 20
bool isReplace,
const char* theExtension)
{
- TCollection_AsciiString aPath((char*)thePath);
+ //TCollection_AsciiString aPath((char*)thePath);
+ std::string aPath((char*)thePath);
if(!isReplace) {
if(theExtension == NULL) aPath += ".asc";
else aPath += (char*)theExtension;
}
- TCollection_AsciiString aFileName(aPath);
+ //TCollection_AsciiString aFileName(aPath);
+ std::string aFileName(aPath);
if(isReplace) aFileName=aPath+".ascii_tmp";
HDFfile *hdf_file = new HDFfile((char*)thePath);
char name[HDF_NAME_MAX_LEN+1];
int nbsons = hdf_file->nInternalObjects(), nbAttr = hdf_file->nAttributes();
- FILE* fp = fopen(aFileName.ToCString(), "w");
+ //FILE* fp = fopen(aFileName.ToCString(), "w");
+ FILE* fp = fopen(aFileName.c_str(), "w");
fprintf(fp, "%s\n", ASCIIHDF_ID);
fprintf(fp, "%i\n", nbsons+nbAttr);
hdf_attribute = 0;
}
- for (Standard_Integer i=0; i<nbsons; i++) {
+ //for (Standard_Integer i=0; i<nbsons; i++) {
+ for (int i=0; i<nbsons; i++) {
hdf_file->InternalObjectIndentify(i,name);
if (strncmp(name, "INTERNAL_COMPLEX",16) == 0) continue;
delete hdf_file;
if(isReplace) {
- OSD_Path anOSDPath(aFileName);
- OSD_File anOSDFile(anOSDPath);
- if(anOSDFile.Exists())
- anOSDFile.Move(aPath);
- else
+// OSD_Path anOSDPath(aFileName);
+// OSD_File anOSDFile(anOSDPath);
+// if(anOSDFile.Exists())
+// anOSDFile.Move(aPath);
+// else
+// return NULL;
+ if(access (aFileName.c_str() , F_OK ) == 0) {
+ rename(aFileName.c_str(), aPath.c_str());
+ }
+ else
return NULL;
}
- int length = strlen(aPath.ToCString());
+ //int length = strlen(aPath.ToCString());
+ int length = strlen(aPath.c_str());
char *new_str = new char[ 1+length ];
- strcpy(new_str , aPath.ToCString()) ;
+ //strcpy(new_str , aPath.ToCString()) ;
+ strcpy(new_str , aPath.c_str()) ;
return new_str;
}
{
hdf_group->OpenOnDisk();
- TCollection_AsciiString anIdent(ident, '\t');
+ //TCollection_AsciiString anIdent(ident, '\t');
+ std::ostringstream oss;
+ oss << ident;
+ std::string anIdent(oss.str());
int nbsons = hdf_group->nInternalObjects(), nbAttr = hdf_group->nAttributes();
/*fprintf(fp, "%s%s\n", anIdent.ToCString(), GROUP_ID);*/
hdf_byte_order order = hdf_dataset->GetOrder();
int nbAttr = hdf_dataset->nAttributes();
- TCollection_AsciiString anIdent(ident, '\t');
- TCollection_AsciiString anIdentChild(ident+1, '\t');
+// TCollection_AsciiString anIdent(ident, '\t');
+// TCollection_AsciiString anIdentChild(ident+1, '\t');
+ std::ostringstream oss;
+ std::ostringstream oss2;
+ oss << ident;
+ oss2 << ident+1;
+ std::string anIdent(oss.str());
+ std::string anIdentChild(oss2.str());
char* name = makeName(hdf_dataset->GetName());
hdf_type type = hdf_attribute->GetType();
- TCollection_AsciiString anIdent(ident, '\t');
- TCollection_AsciiString anIdentChild(ident+1, '\t');
+ //TCollection_AsciiString anIdent(ident, '\t');
+ //TCollection_AsciiString anIdentChild(ident+1, '\t');
+ std::ostringstream oss;
+ std::ostringstream oss2;
+ oss << ident;
+ oss2 << ident+1;
+ std::string anIdent(oss.str());
+ std::string anIdentChild(oss2.str());
char* name = makeName(hdf_attribute->GetName());
int size = hdf_attribute->GetSize();
char* HDFascii::ConvertFromASCIIToHDF(const char* thePath)
{
// Get a temporary directory to store a file
- TCollection_AsciiString aTmpDir = GetTmpDir(), aFileName("hdf_from_ascii.hdf");
+ //TCollection_AsciiString aTmpDir = GetTmpDir(), aFileName("hdf_from_ascii.hdf");
+ std::string aTmpDir = GetTmpDir();
+ std::string aFileName("hdf_from_ascii.hdf");
// Build a full file name of temporary file
- TCollection_AsciiString aFullName = aTmpDir + aFileName;
+ //TCollection_AsciiString aFullName = aTmpDir + aFileName;
+ std::string aFullName = aTmpDir + aFileName;
- HDFfile *hdf_file = new HDFfile(aFullName.ToCString());
+ //HDFfile *hdf_file = new HDFfile(aFullName.ToCString());
+ HDFfile *hdf_file = new HDFfile((char *) aFullName.c_str());
hdf_file->CreateOnDisk();
FILE *fp = fopen(thePath, "r");
hdf_file->CloseOnDisk();
delete hdf_file;
- int length = strlen(aTmpDir.ToCString());
+ //int length = strlen(aTmpDir.ToCString());
+ int length = strlen(aTmpDir.c_str());
+ cerr << "length : " << length << endl;
char *new_str = new char[ 1+length ];
- strcpy(new_str , aTmpDir.ToCString()) ;
+ //strcpy(new_str , aTmpDir.ToCString()) ;
+ strcpy(new_str , aTmpDir.c_str()) ;
+
+ cerr << "test ::: " << aTmpDir << endl;
+ cerr << "test ::: " << new_str << endl;
return new_str;
}
{
//Find a temporary directory to store a file
- TCollection_AsciiString aTmpDir;
+ //TCollection_AsciiString aTmpDir;
+ std::string aTmpDir;
#ifdef WNT
char *aTmp;
aTmp = getenv("TMP");
- if(aTmp != NULL)
- aTmpDir = TCollection_AsciiString(aTmp);
- else
- aTmpDir = TCollection_AsciiString("C:\\");
+ if(aTmp != NULL) {
+// aTmpDir = TCollection_AsciiString(aTmp);
+ aTmpDir = std::string(aTmp);
+ }
+ else {
+// aTmpDir = TCollection_AsciiString("C:\\");
+ aTmpDir = std::string("C:\\");
+ }
#else
- aTmpDir = TCollection_AsciiString("/tmp/");
+ //aTmpDir = TCollection_AsciiString("/tmp/");
+ aTmpDir = std::string("/tmp/");
#endif
srand((unsigned int)time(NULL));
int aRND = 999 + (int)(100000.0*rand()/(RAND_MAX+1.0)); //Get a random number to present a name of a sub directory
- TCollection_AsciiString aSubDir(aRND);
- if(aSubDir.Length() <= 1) aSubDir = TCollection_AsciiString("123409876");
+// TCollection_AsciiString aSubDir(aRND);
+// if(aSubDir.Length() <= 1) aSubDir = TCollection_AsciiString("123409876");
+ std::ostringstream oss;
+ oss << aRND;
+ std::string aSubDir(oss.str());
+ if(aSubDir.length() <= 1) aSubDir = std::string("123409876");
aTmpDir += aSubDir; //Get RND sub directory
#ifdef WIN32
- if(aTmpDir.Value(aTmpDir.Length()) != '\\') aTmpDir+='\\';
+// if(aTmpDir.Value(aTmpDir.Length()) != '\\') aTmpDir+='\\';
+ if(aTmpDir[aTmpDir.length()-1] != '\\') aTmpDir+='\\';
#else
- if(aTmpDir.Value(aTmpDir.Length()) != '/') aTmpDir+='/';
+// if(aTmpDir.Value(aTmpDir.Length()) != '/') aTmpDir+='/';
+ if(aTmpDir[aTmpDir.length()-1] != '/') aTmpDir+='/';
#endif
- OSD_Path aPath(aTmpDir);
- OSD_Directory aDir(aPath);
+// OSD_Path aPath(aTmpDir);
+// OSD_Directory aDir(aPath);
+ std::string aDir(aTmpDir);
- for(aRND = 0; aDir.Exists(); aRND++) {
- aTmpDir.Insert((aTmpDir.Length() - 1), TCollection_AsciiString(aRND)); //Build a unique directory name
- aPath = OSD_Path(aTmpDir);
- aDir = OSD_Directory(aPath);
- }
+ //std::cerr << "temp dir .... : " << aTmpDir << std::endl;
- OSD_Protection aProtection(OSD_RW, OSD_RWX, OSD_RX, OSD_RX);
- aDir.Build(aProtection);
+ for(aRND = 0; directoryExists(aDir.c_str()); aRND++) {
+ //aTmpDir.Insert((aTmpDir.Length() - 1), TCollection_AsciiString(aRND)); //Build a unique directory name
+ aTmpDir.insert((aTmpDir.length() - 1), oss.str()); //Build a unique directory name
+ std::cerr << "Tempory directory exist, changing name ..." << std::endl;
+ std::cerr << "temp dir .... : " << aTmpDir << std::endl;
+ aDir = std::string(aTmpDir);
+// aPath = OSD_Path(aTmpDir);
+// aDir = OSD_Directory(aPath);
+ }
- int length = strlen(aTmpDir.ToCString());
+ //OSD_Protection aProtection(OSD_RW, OSD_RWX, OSD_RX, OSD_RX);
+ //aDir.Build(aProtection);
+ createDirectory(aDir.c_str());
+ //int length = strlen(aTmpDir.ToCString());
+ int length = strlen(aTmpDir.c_str());
char *new_str = new char[ 1+length ];
- strcpy(new_str , aTmpDir.ToCString());
-
+ //strcpy(new_str , aTmpDir.ToCString());
+ strcpy(new_str , aTmpDir.c_str());
return new_str;
}
char* makeName(char* name)
{
- TCollection_AsciiString aName(name), aNewName;
- Standard_Integer i, length = aName.Length();
+ //TCollection_AsciiString aName(name), aNewName;
+ std::string aName(name), aNewName;
+ //Standard_Integer i, length = aName.Length();
+ int i, length = aName.length();
char replace = (char)19;
for(i=1; i<=length; i++) {
- if(aName.Value(i) == ' ') aNewName+=replace;
- else aNewName += aName.Value(i);
+ //if(aName.Value(i) == ' ') aNewName+=replace;
+ //else aNewName += aName.Value(i);
+ if(aName[i] == ' ') aNewName+=replace;
+ else aNewName += aName[i];
}
- length = strlen(aNewName.ToCString());
+ //length = strlen(aNewName.ToCString());
+ length = strlen(aNewName.c_str());
char *new_str = new char[ 1+length ];
- strcpy(new_str , aNewName.ToCString()) ;
+ //strcpy(new_str , aNewName.ToCString()) ;
+ strcpy(new_str , aNewName.c_str()) ;
return new_str;
}
char* restoreName(char* name)
{
- TCollection_AsciiString aName(name), aNewName;
- Standard_Integer i, length = aName.Length();
+ //TCollection_AsciiString aName(name), aNewName;
+ std::string aName(name), aNewName;
+ //Standard_Integer i, length = aName.Length();
+ int i, length = aName.length();
char replace = (char)19;
for(i=1; i<=length; i++) {
- if(aName.Value(i) == replace) aNewName+=' ';
- else aNewName += aName.Value(i);
+ //if(aName.Value(i) == replace) aNewName+=' ';
+ //else aNewName += aName.Value(i);
+ if(aName[i] == replace) aNewName+=' ';
+ else aNewName += aName[i];
}
- length = strlen(aNewName.ToCString());
+ //length = strlen(aNewName.ToCString());
+ length = strlen(aNewName.c_str());
char *new_str = new char[ 1+length ];
- strcpy(new_str , aNewName.ToCString()) ;
+ //strcpy(new_str , aNewName.ToCString()) ;
+ strcpy(new_str , aNewName.c_str()) ;
return new_str;
}
array[i] = (unsigned char)tmp;
}
}
+
+bool directoryExists(const char* dir)
+{
+ DIR* dhandle = opendir(dir);
+
+ if (dhandle != NULL)
+ {
+ closedir(dhandle);
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+}
+
+bool createDirectory(const char* dir)
+{
+ return mkdir(dir, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH) == 0;
+}
+
+bool is_readable( const std::string & file )
+{
+ std::ifstream fichier( file.c_str() );
+ return !fichier.fail();
+}
#ifndef __HDFascii_H__
#define __HDFascii_H__
-#include <Standard_Macro.hxx>
+#include "HDFexport.hxx"
-class Standard_EXPORT HDFascii
+class HDF_EXPORT HDFascii
{
public:
}
#include "HDFcontainerObject.hxx"
#include "HDFexception.hxx"
-#include "utilities.h"
+//#include "utilities.h"
using namespace std;
HDFcontainerObject::HDFcontainerObject(char *name)
}
#include "HDFobject.hxx"
#include "HDFinternalObject.hxx"
-#include <Standard_Macro.hxx>
+#include "HDFexport.hxx"
-class Standard_EXPORT HDFcontainerObject : public HDFinternalObject
+class HDF_EXPORT HDFcontainerObject : public HDFinternalObject
{
private :
HDFinternalObject *_firstson;
}
#include "HDFinternalObject.hxx"
#include "HDFcontainerObject.hxx"
-#include <Standard_Macro.hxx>
+#include "HDFexport.hxx"
-class Standard_EXPORT HDFdataset : public HDFinternalObject
+class HDF_EXPORT HDFdataset : public HDFinternalObject
{
private :
HDFcontainerObject *_father;
--- /dev/null
+// Copyright (C) 2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : HDFexport.hxx
+// Author : Andre Ribes - EDF R&D
+// Module : SALOME
+
+#ifndef _HDF_export_HXX_
+#define _HDF_export_HXX_
+
+#ifdef WNT
+ #if defined WIN32
+ #define HDF_EXPORT __declspec( dllimport )
+ #else
+ #define HDF_EXPORT
+ #endif
+#else
+ #define HDF_EXPORT
+#endif
+
+#endif
#include "HDFtypes.h"
}
#include "HDFcontainerObject.hxx"
-#include <Standard_Macro.hxx>
+#include "HDFexport.hxx"
-class Standard_EXPORT HDFfile : public HDFcontainerObject
+class HDF_EXPORT HDFfile : public HDFcontainerObject
{
private :
hdf_access_mode _access_mode;
#include "HDFtypes.h"
}
#include "HDFcontainerObject.hxx"
-#include <Standard_Macro.hxx>
+#include "HDFexport.hxx"
-class Standard_EXPORT HDFgroup : public HDFcontainerObject
+class HDF_EXPORT HDFgroup : public HDFcontainerObject
{
private :
HDFcontainerObject *_father;
#include "HDFtypes.h"
}
#include "HDFobject.hxx"
-#include <Standard_Macro.hxx>
+#include "HDFexport.hxx"
-class Standard_EXPORT HDFinternalObject : public HDFobject
+class HDF_EXPORT HDFinternalObject : public HDFobject
{
private :
HDFinternalObject *_previousbrother;
#include "hdfi.h"
#include <string.h>
}
-#include "utilities.h"
+//#include "utilities.h"
using namespace std;
HDFobject::HDFobject(char *name)
{
#include "HDFtypes.h"
}
-#include <Standard_Macro.hxx>
+#include <HDFexport.hxx>
-class Standard_EXPORT HDFobject {
+class HDF_EXPORT HDFobject {
protected :
char *_name;
hdf_idt _id;
HDFtypes.h \
HDFconvert.hxx \
hdfi.h \
- HDFascii.hxx
+ HDFascii.hxx \
+ HDFexport.hxx
# Libraries targets
lib_LTLIBRARIES = libSalomeHDFPersist.la
HDFascii.cc
libSalomeHDFPersist_la_LDFLAGS = -no-undefined -version-info=0:0:0
-libSalomeHDFPersist_la_CPPFLAGS = @CAS_CPPFLAGS@ @HDF5_INCLUDES@ -DPCLINUX \
+
+#libSalomeHDFPersist_la_CPPFLAGS = @CAS_CPPFLAGS@ @HDF5_INCLUDES@ -DPCLINUX \
+libSalomeHDFPersist_la_CPPFLAGS = @HDF5_INCLUDES@ -DPCLINUX \
-I$(srcdir)/../SALOMELocalTrace \
-I$(srcdir)/../Basics
-libSalomeHDFPersist_la_LIBADD = @CAS_KERNEL@ @HDF5_LIBS@
-
+#libSalomeHDFPersist_la_LIBADD = @CAS_KERNEL@ @HDF5_LIBS@
+libSalomeHDFPersist_la_LIBADD = @HDF5_LIBS@
EXTRA_DIST = \
test1.c \
-I$(top_builddir)/salome_adm/unix \
-I$(top_builddir)/idl \
-I$(top_srcdir)/src/SALOMETraceCollector \
- @CAS_CPPFLAGS@ @CAS_CXXFLAGS@ \
@CORBA_CXXFLAGS@ \
@CORBA_INCLUDES@ \
@PACO_INCLUDES@
isValidScript = true;
return aStreamFile._retn();
}
+
+Engines::Salome_file_ptr
+Engines_Parallel_Component_i::getInputServiceSalome_file(const char* service_name,
+ const char* Salome_file_name)
+{
+ // Try to find the service, if it doesn't exist, we throw an exception.
+ _Service_file_map_it = _Input_Service_file_map.find(service_name);
+ if (_Service_file_map_it == _Input_Service_file_map.end()) {
+ SALOME::ExceptionStruct es;
+ es.type = SALOME::INTERNAL_ERROR;
+ es.text = "service doesn't have salome files";
+ throw SALOME::SALOME_Exception(es);
+ }
+ _t_Salome_file_map * _map = _Input_Service_file_map[service_name];
+
+ // Try to find the Salome_file ...
+ _Salome_file_map_it = _map->find(Salome_file_name);
+ if (_Salome_file_map_it == _map->end()) {
+ SALOME::ExceptionStruct es;
+ es.type = SALOME::INTERNAL_ERROR;
+ es.text = "service doesn't have this Salome_file";
+ throw SALOME::SALOME_Exception(es);
+ }
+ Salome_file_i * Sfile = (*_map)[Salome_file_name];
+
+ return Sfile->_this();
+}
+
+Engines::Salome_file_ptr
+Engines_Parallel_Component_i::setInputFileToService(const char* service_name,
+ const char* Salome_file_name)
+{
+ // Try to find the service, if it doesn't exist, we add it.
+ _Service_file_map_it = _Input_Service_file_map.find(service_name);
+ if (_Service_file_map_it == _Input_Service_file_map.end()) {
+ _t_Salome_file_map * _map = new _t_Salome_file_map();
+ _Input_Service_file_map[service_name] = _map;
+ }
+ _t_Salome_file_map * _map = _Input_Service_file_map[service_name];
+
+ // Try to find the Salome_file ...
+ _Salome_file_map_it = _map->find(Salome_file_name);
+ if (_Salome_file_map_it == _map->end()) {
+ Salome_file_i * Sfile = new Salome_file_i();
+ (*_map)[Salome_file_name] = Sfile;
+ }
+ else {
+ // Salome_file_name already added into the service
+ // throw Exception
+ SALOME::ExceptionStruct es;
+ es.type = SALOME::INTERNAL_ERROR;
+ es.text = "Salome_file_name already added";
+ throw SALOME::SALOME_Exception(es);
+ }
+ Salome_file_i * Sfile = (*_map)[Salome_file_name];
+
+ return Sfile->_this();
+}
+
+void
+Engines_Parallel_Component_i::checkInputServiceFiles(const char* service_name)
+{
+ // Try to find the service, if it doesn't exist, nothing to do.
+ _Service_file_map_it = _Input_Service_file_map.find(service_name);
+ if (_Service_file_map_it != _Input_Service_file_map.end()) {
+ _t_Salome_file_map * _map = _Input_Service_file_map[service_name];
+ _t_Salome_file_map::iterator begin = _map->begin();
+ _t_Salome_file_map::iterator end = _map->end();
+
+ for(;begin!=end;begin++) {
+ Salome_file_i * file = begin->second;
+ file->recvFiles();
+ }
+ }
+
+}
+
+Engines::Salome_file_ptr
+Engines_Parallel_Component_i::getOutputServiceSalome_file(const char* service_name,
+ const char* Salome_file_name)
+{
+ // Try to find the service, if it doesn't exist, we throw an exception.
+ _Service_file_map_it = _Output_Service_file_map.find(service_name);
+ if (_Service_file_map_it == _Output_Service_file_map.end()) {
+ SALOME::ExceptionStruct es;
+ es.type = SALOME::INTERNAL_ERROR;
+ es.text = "service doesn't have salome files";
+ throw SALOME::SALOME_Exception(es);
+ }
+ _t_Salome_file_map * _map = _Output_Service_file_map[service_name];
+
+ // Try to find the Salome_file ...
+ _Salome_file_map_it = _map->find(Salome_file_name);
+ if (_Salome_file_map_it == _map->end()) {
+ SALOME::ExceptionStruct es;
+ es.type = SALOME::INTERNAL_ERROR;
+ es.text = "service doesn't have this Salome_file";
+ throw SALOME::SALOME_Exception(es);
+ }
+ Salome_file_i * Sfile = (*_map)[Salome_file_name];
+
+ return Sfile->_this();
+}
+
+Engines::Salome_file_ptr
+Engines_Parallel_Component_i::setOutputFileToService(const char* service_name,
+ const char* Salome_file_name)
+{
+ // Try to find the service, if it doesn't exist, we add it.
+ _Service_file_map_it = _Output_Service_file_map.find(service_name);
+ if (_Service_file_map_it == _Output_Service_file_map.end()) {
+ _t_Salome_file_map * _map = new _t_Salome_file_map();
+ _Output_Service_file_map[service_name] = _map;
+ }
+ _t_Salome_file_map * _map = _Output_Service_file_map[service_name];
+
+ // Try to find the Salome_file ...
+ _Salome_file_map_it = _map->find(Salome_file_name);
+ if (_Salome_file_map_it == _map->end()) {
+ Salome_file_i * Sfile = new Salome_file_i();
+ (*_map)[Salome_file_name] = Sfile;
+ }
+ else {
+ // Salome_file_name already added into the service
+ // throw Exception
+ SALOME::ExceptionStruct es;
+ es.type = SALOME::INTERNAL_ERROR;
+ es.text = "Salome_file_name already added";
+ throw SALOME::SALOME_Exception(es);
+ }
+ Salome_file_i * Sfile = (*_map)[Salome_file_name];
+
+ return Sfile->_this();
+}
+
+void
+Engines_Parallel_Component_i::checkOutputServiceFiles(const char* service_name)
+{
+ // Try to find the service, if it doesn't exist, nothing to do.
+ _Service_file_map_it = _Output_Service_file_map.find(service_name);
+ if (_Service_file_map_it != _Output_Service_file_map.end()) {
+ _t_Salome_file_map * _map = _Output_Service_file_map[service_name];
+ _t_Salome_file_map::iterator begin = _map->begin();
+ _t_Salome_file_map::iterator end = _map->end();
+
+ for(;begin!=end;begin++) {
+ Salome_file_i * file = begin->second;
+ file->recvFiles();
+ }
+ }
+
+}
+
#include "NOTIFICATION.hxx"
#include "RegistryConnexion.hxx"
+#include "Salome_file_i.hxx"
class Engines_Parallel_Container_i;
CORBA::Boolean isPublished,
CORBA::Boolean& isValidScript);
+ virtual Engines::Salome_file_ptr getInputServiceSalome_file(const char* service_name,
+ const char* Salome_file_name);
+ virtual Engines::Salome_file_ptr getOutputServiceSalome_file(const char* service_name,
+ const char* Salome_file_name);
+
+ virtual void checkInputServiceFiles(const char* service_name);
+ virtual Engines::Salome_file_ptr setInputFileToService(const char* service_name,
+ const char* Salome_file_name);
+
+ virtual void checkOutputServiceFiles(const char* service_name);
+ virtual Engines::Salome_file_ptr setOutputFileToService(const char* service_name,
+ const char* Salome_file_name);
// --- local C++ methods
NOTIFICATION_Supplier* _notifSupplier;
std::map<std::string,CORBA::Any>_fieldsDict;
+ // Map Salome_file_name to Salome_file*
+ typedef std::map<std::string, Salome_file_i*> _t_Salome_file_map;
+ // Map Service_name to _Salome_file_map
+ typedef std::map<std::string, Engines_Parallel_Component_i::_t_Salome_file_map*> _t_Service_file_map;
+
+ _t_Service_file_map _Input_Service_file_map;
+ _t_Service_file_map _Output_Service_file_map;
+ _t_Service_file_map::iterator _Service_file_map_it;
+ _t_Salome_file_map::iterator _Salome_file_map_it;
+
std::string _serviceName ;
std::string _graphName ;
std::string _nodeName ;