// By default this method does nothing
}
+//=============================================================================
+/*!
+ * C++ method: allows to import data file into the Component internal data
+ structure (like import operation of BRep file in GEOM module).
+ * \param studyId identifier of the working study
+ * \param data container of the file content
+ * \param options additional options for import (if needed)
+ */
+//=============================================================================
+Engines::ListOfIdentifiers* Engines_Component_i::importData(CORBA::Long studyId,
+ Engines::DataContainer_ptr data,
+ const Engines::ListOfOptions& options)
+{
+ // By default this method does nothing
+ Engines::ListOfIdentifiers_var aList = new Engines::ListOfIdentifiers;
+ return aList._retn();
+}
+
+//=============================================================================
+/*!
+ * C++ method: allows to export data files from the Component internal data
+ structure (like Export operation of Step file in GEOM module).
+ * \param studyId identifier of the working study
+ */
+//=============================================================================
+Engines::ListOfData* Engines_Component_i::getModifiedData(CORBA::Long studyId)
+{
+ // By default this method does nothing
+ Engines::ListOfData_var aList = new Engines::ListOfData;
+ return aList._retn();
+}
+
//=============================================================================
/*!
* C++ method: return the name of the container associated with this component
salomeinclude_HEADERS = \
SALOME_Component_i.hxx \
SALOME_Container_i.hxx \
+ SALOME_DataContainer_i.hxx \
SALOME_FileTransfer_i.hxx \
SALOME_FileRef_i.hxx \
SALOME_ContainerManager.hxx \
dist_salomescript_PYTHON =\
SALOME_ComponentPy.py \
SALOME_PyNode.py \
- SALOME_Container.py
+ SALOME_Container.py \
+ SALOME_DataContainerPy.py
# These files are executable scripts
dist_salomescript_SCRIPTS=\
libSalomeContainer_la_SOURCES=\
Component_i.cxx \
Container_i.cxx \
+ SALOME_DataContainer_i.cxx \
SALOME_FileTransfer_i.cxx \
SALOME_FileRef_i.cxx \
Container_init_python.cxx \
def getObjectInfo(self, studyId, entry):
return ""
+
+ def importData(self, studyId, dataContainer, options):
+ return [] # no implmenetation by default
+
+ def getModifiedData(self, studyId):
+ return [] # no implmenetation by default
std::string file_port_name,
Salome_file_i * file);
+ virtual Engines::ListOfIdentifiers* importData(
+ CORBA::Long studyId, Engines::DataContainer_ptr data, const Engines::ListOfOptions& options);
+ virtual Engines::ListOfData* getModifiedData(CORBA::Long studyId);
protected:
int _studyId; // -1: not initialised; 0: multiStudy; >0: study
--- /dev/null
+#! /usr/bin/env python
+# -*- coding: iso-8859-1 -*-
+# Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
+#
+# Copyright (C) 2003-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.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+
+# SALOME DataContainer : implementation of data container
+# File : SALOME_DataContainerPy.py
+# Author : Mikhail PONIKARIOV
+# Module : SALOME
+# $Header$
+#
+import os
+import sys
+import string
+
+from omniORB import CORBA, PortableServer
+import Engines, Engines__POA
+from SALOME_ComponentPy import *
+
+#=============================================================================
+
+#define an implementation of the data container interface for the data transfer implemented in Python
+
+class SALOME_DataContainerPy_i (Engines__POA.DataContainer):
+ _url = ""
+ _name = ""
+ _identifier = ""
+ _ext = -1
+ _removeAfterGet = True;
+
+ #-------------------------------------------------------------------------
+
+ def __init__(self, url, name, identifier, removeAfterGet):
+ self._url = url
+ self._name = name
+ self._identifier = identifier
+ self._removeAfterGet = removeAfterGet
+ self._ext = url[url.rfind(".") + 1 : ]
+
+ #-------------------------------------------------------------------------
+
+ def get(self):
+ f = open(self._url, 'r')
+ stream = f.read()
+ f.close()
+ if self._removeAfterGet:
+ os.remove(self._url)
+ try: # try to remove directory if it is empty
+ index = max(self._url.rfind("\\"), self._url.rfind("/"))
+ if index > 0:
+ os.rmdir(self._url[:index])
+ except:
+ pass
+ return stream
+
+ #-------------------------------------------------------------------------
+
+ def name(self):
+ return self._name
+
+ #-------------------------------------------------------------------------
+
+ def identifier(self):
+ return self._identifier
+
+ def extension(self):
+ return self._ext
--- /dev/null
+// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-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.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+// SALOME DataContainer : implementation of data container
+// File : SALOME_DataContainer_i.cxx
+// Author : Mikhail PONIKAROV
+// Module : SALOME
+// $Header$
+//
+
+#include <SALOME_DataContainer_i.hxx>
+
+#include <fstream>
+#include <iostream>
+
+using namespace std;
+
+Engines_DataContainer_i::Engines_DataContainer_i()
+{
+}
+
+Engines_DataContainer_i::Engines_DataContainer_i(const char* url,
+ const char* name, const char* identifier, const bool removeAfterGet)
+ : myName(name), myIdentifier(identifier), myURL(url), myRemoveAfterGet(removeAfterGet)
+{
+ std::string anExtension(url);
+ if (anExtension.rfind(".") != std::string::npos) { // keep only extension
+ myExt = anExtension.substr(anExtension.rfind(".") + 1);
+ } else myExt = "";
+}
+
+Engines_DataContainer_i::~Engines_DataContainer_i()
+{
+}
+
+Engines::TMPFile* Engines_DataContainer_i::get()
+{
+ // open file to make stream from its content
+#ifdef WIN32
+ ifstream aFile(myURL.c_str(), std::ios::binary);
+#else
+ ifstream aFile(myURL.c_str());
+#endif
+ if (!aFile.good()) {
+ std::cerr<<"File "<<myURL.c_str()<<" can not be opened for reading"<<std::endl;
+ }
+ aFile.seekg(0, std::ios::end);
+ int aFileSize = aFile.tellg();
+ char* aBuffer = new char[aFileSize];
+
+ aFile.seekg(0, std::ios::beg);
+ aFile.read(aBuffer, aFileSize);
+ aFile.close();
+
+ // remove file after it converted to a stream
+ if (myRemoveAfterGet) {
+ #ifdef WIN32
+ DeleteFile(myURL.c_str());
+ #else
+ unlink(myURL.c_str());
+ #endif
+ }
+
+ // make CORBA TMP file from the buffer
+ CORBA::Octet* anOctetBuf = (CORBA::Octet*)aBuffer;
+ Engines::TMPFile_var aStreamFile = new Engines::TMPFile(aFileSize, aFileSize, anOctetBuf, 1);
+
+ return aStreamFile._retn();
+}
+
+char* Engines_DataContainer_i::name()
+{
+ return CORBA::string_dup(myName.c_str());
+}
+
+char* Engines_DataContainer_i::identifier()
+{
+ return CORBA::string_dup(myIdentifier.c_str());
+}
+
+char* Engines_DataContainer_i::extension()
+{
+ return CORBA::string_dup(myExt.c_str());
+}
--- /dev/null
+// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-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.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+// SALOME DataContainer : implementation of data container
+// File : SALOME_DataContainer_i.hxx
+// Author : Mikhail PONIKAROV
+// Module : SALOME
+// $Header$
+//
+#ifndef _SALOME_DATACONTAINER_I_HXX_
+#define _SALOME_DATACONTAINER_I_HXX_
+
+#include "SALOME_Container.hxx"
+
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(SALOME_Component)
+
+#include <string>
+
+class CONTAINER_EXPORT Engines_DataContainer_i:
+ public POA_Engines::DataContainer
+{
+public:
+ Engines_DataContainer_i();
+ Engines_DataContainer_i(const char* url,
+ const char* name,
+ const char* identifier,
+ const bool removeAfterGet);
+ virtual ~Engines_DataContainer_i();
+
+ // --- CORBA methods
+ virtual Engines::TMPFile* get();
+ virtual char* name();
+ virtual char* identifier();
+ virtual char* extension();
+
+protected:
+
+ std::string myExt; ///< extension (type) of the file
+ std::string myName; ///< name of the document corresponding to this data
+ std::string myIdentifier; ///< module identifier of the document corresponding to this data
+ std::string myURL; ///< path to the locally located file
+ bool myRemoveAfterGet; ///< if this flag is true, file must be removed after the first "get" method call
+};
+
+#endif