]> SALOME platform Git repositories - modules/yacs.git/blobdiff - src/engine/Runtime.cxx
Salome HOME
mergefrom branch BR_V511_PR tag mergeto_trunk_03feb09
[modules/yacs.git] / src / engine / Runtime.cxx
index 6bfae836897754e9cff5acb32ec8557974ab36de..89a97c40e2e7f02d23bb5bfa82b445dc25cee12e 100644 (file)
@@ -1,3 +1,21 @@
+//  Copyright (C) 2006-2008  CEA/DEN, EDF R&D
+//
+//  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
+//
 #include "Runtime.hxx"
 
 #include<cassert>
 #include "OutputDataStreamPort.hxx"
 #include "Catalog.hxx"
 #include "TypeCode.hxx"
+#include "Executor.hxx"
 
 #include<iostream>
+#include<cstdlib>
 
 //#define _DEVDEBUG_
 #include "YacsTrace.hxx"
@@ -71,6 +91,13 @@ Runtime::Runtime()
   typeMap["string"]=Runtime::_tc_string;
   Runtime::_tc_file->incrRef();
   typeMap["file"]=Runtime::_tc_file;
+
+  char *maxThreadStr = getenv("YACS_MAX_THREADS");
+  if (!maxThreadStr) return;
+  int maxThreads = atoi(maxThreadStr);
+  DEBTRACE("maxThreads = " << maxThreads);
+  if (maxThreads <1) return;
+  Executor::_maxThreads = maxThreads;
 }
 
 void Runtime::removeRuntime()
@@ -248,3 +275,32 @@ TypeCode* Runtime::getTypeCode(const std::string& name)
   return 0;
 }
 
+//! Convert a YACS::ENGINE::Any object to an external object with type type
+/*!
+ * This method is used to convert Neutral objects to script languages. For example
+ * Python language. The runtime has one external script language.
+ * The object is returned as a void * because engine knows nothing about external script language.
+ *
+ * \param type: the type of the converted object if the conversion is possible
+ * \param data: the object to convert
+ * \return the converted object
+ */
+void* Runtime::convertNeutral(TypeCode * type, Any *data)
+{
+  throw Exception("convertNeutral is not implemented by your runtime");
+}
+
+//! Convert a YACS::ENGINE::Any object to a string to be used in GUI for example
+/*!
+ * engine package does not provide a conversion to string. It has to be implemented in the 
+ * runtime package.
+ *
+ * \param type: the type of the object to convert
+ * \param data: the object to convert
+ * \return the string representation of the object
+ */
+std::string Runtime::convertNeutralAsString(TypeCode * type, Any *data)
+{
+  throw Exception("convertNeutralAsString is not implemented by your runtime");
+}
+