Version: 9.16.0
SalomeProc.cxx
Go to the documentation of this file.
1// Copyright (C) 2006-2026 CEA, EDF
2//
3// This library is free software; you can redistribute it and/or
4// modify it under the terms of the GNU Lesser General Public
5// License as published by the Free Software Foundation; either
6// version 2.1 of the License, or (at your option) any later version.
7//
8// This library is distributed in the hope that it will be useful,
9// but WITHOUT ANY WARRANTY; without even the implied warranty of
10// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11// Lesser General Public License for more details.
12//
13// You should have received a copy of the GNU Lesser General Public
14// License along with this library; if not, write to the Free Software
15// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16//
17// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18//
19
20#include <Python.h>
21#include "SalomeProc.hxx"
22#include "Runtime.hxx"
23#include "TypeCode.hxx"
24#include "Container.hxx"
26#include "Basics_Utils.hxx"
27#include <iostream>
28#include <cstdlib>
29
30using namespace YACS::ENGINE;
31
32SalomeProc::SalomeProc(const std::string& name):Proc(name)
33{
34 // create default container with some default properties
35 Container* cont=createContainer("DefaultContainer");
36 cont->setProperty("name", "localhost");
37 cont->setProperty("container_name","FactoryServer");
38 cont->decrRef();
39}
40
41TypeCode * SalomeProc::createInterfaceTc(const std::string& id, const std::string& name,
42 std::list<TypeCodeObjref *> ltc)
43{
44 std::string myName;
45 if(id == "") myName = "IDL:" + name + ":1.0";
46 else myName = id;
47 return Proc::createInterfaceTc(myName,name,ltc);
48}
49TypeCode * SalomeProc::createStructTc(const std::string& id, const std::string& name)
50{
51 std::string myName;
52 if(id == "") myName = "IDL:" + name + ":1.0";
53 else myName = id;
54 return Proc::createStructTc(myName,name);
55}
56
58{
59}
60
62
65void SalomeProc::saveSchema(std::string xmlSchemaFile)
66{
68 vss.openFileSchema(xmlSchemaFile);
69 accept(&vss);
70 vss.closeFileSchema();
71}
72
74void SalomeProc::init(bool start)
75{
76 //initialise Python module salome with the study id given by value
77 std::string cmd="import salome;salome.salome_init()";
78 PyGILState_STATE gstate = PyGILState_Ensure(); // acquire the Global Interpreter Lock
79 PyRun_SimpleString(cmd.c_str());
80 PyGILState_Release(gstate); // Release the Global Interpreter Lock
81 Proc::init(start);
82}
void init(bool start=true)
Initialize the bloc.
Definition: Bloc.cxx:95
virtual void setProperty(const std::string &name, const std::string &value)=0
Base class for all schema objects.
Definition: Proc.hxx:44
virtual Container * createContainer(const std::string &name, const std::string &kind="")
Create a new Container and store it in containerMap.
Definition: Proc.cxx:506
virtual void accept(Visitor *visitor)
Definition: Proc.cxx:199
virtual TypeCode * createStructTc(const std::string &id, const std::string &name)
Definition: Proc.cxx:161
virtual TypeCode * createInterfaceTc(const std::string &id, const std::string &name, std::list< TypeCodeObjref * > ltc)
Create an object reference TypeCode.
Definition: Proc.cxx:132
virtual TypeCode * createInterfaceTc(const std::string &id, const std::string &name, std::list< TypeCodeObjref * > ltc)
Create an object reference TypeCode.
Definition: SalomeProc.cxx:41
virtual void init(bool start=true)
Initialise the proc.
Definition: SalomeProc.cxx:74
virtual TypeCode * createStructTc(const std::string &id, const std::string &name)
Definition: SalomeProc.cxx:49
virtual void saveSchema(std::string xmlSchemaFile)
Save Proc in XML schema file.
Definition: SalomeProc.cxx:65
Base class for all type objects.
Definition: TypeCode.hxx:68
void openFileSchema(std::string xmlDump)