Xcos MVC: add ParamsAdapter 22/14922/2
Clément DAVID [Wed, 16 Jul 2014 15:42:03 +0000 (17:42 +0200)]
Change-Id: Ia075ddd42efc645fac2bfbd4a6db472c5277f6bc

15 files changed:
scilab/modules/scicos/Makefile.am
scilab/modules/scicos/Makefile.in
scilab/modules/scicos/includes/utilities.hxx
scilab/modules/scicos/sci_gateway/cpp/sci_scicos_new.cpp
scilab/modules/scicos/src/c/scicos.vcxproj
scilab/modules/scicos/src/c/scicos.vcxproj.filters
scilab/modules/scicos/src/cpp/LoggerView.cpp
scilab/modules/scicos/src/cpp/model/Block.hxx
scilab/modules/scicos/src/cpp/model/Diagram.hxx
scilab/modules/scicos/src/cpp/view_scilab/Adapters.cpp
scilab/modules/scicos/src/cpp/view_scilab/Adapters.hxx
scilab/modules/scicos/src/cpp/view_scilab/DiagramAdapter.cpp
scilab/modules/scicos/src/cpp/view_scilab/DiagramAdapter.hxx
scilab/modules/scicos/src/cpp/view_scilab/ParamsAdapter.cpp [new file with mode: 0644]
scilab/modules/scicos/src/cpp/view_scilab/ParamsAdapter.hxx [new file with mode: 0644]

index b05416e..bff5a98 100644 (file)
@@ -26,6 +26,7 @@ src/cpp/view_scilab/DiagramAdapter.cpp \
 src/cpp/view_scilab/GraphicsAdapter.cpp \
 src/cpp/view_scilab/LinkAdapter.cpp \
 src/cpp/view_scilab/ModelAdapter.cpp \
+src/cpp/view_scilab/ParamsAdapter.cpp \
 src/cpp/view_scilab/ScsAdapter.cpp \
 src/cpp/view_scilab/StateAdapter.cpp \
 src/cpp/view_scilab/TextAdapter.cpp
index 3fdf965..ac9f925 100644 (file)
@@ -212,6 +212,7 @@ am__libsciscicos_algo_la_SOURCES_DIST = src/c/noscicos/noscicos.c \
        src/cpp/view_scilab/GraphicsAdapter.cpp \
        src/cpp/view_scilab/LinkAdapter.cpp \
        src/cpp/view_scilab/ModelAdapter.cpp \
+       src/cpp/view_scilab/ParamsAdapter.cpp \
        src/cpp/view_scilab/ScsAdapter.cpp \
        src/cpp/view_scilab/StateAdapter.cpp \
        src/cpp/view_scilab/TextAdapter.cpp \
@@ -242,6 +243,7 @@ am__objects_2 = src/cpp/libsciscicos_algo_la-Controller.lo \
        src/cpp/view_scilab/libsciscicos_algo_la-GraphicsAdapter.lo \
        src/cpp/view_scilab/libsciscicos_algo_la-LinkAdapter.lo \
        src/cpp/view_scilab/libsciscicos_algo_la-ModelAdapter.lo \
+       src/cpp/view_scilab/libsciscicos_algo_la-ParamsAdapter.lo \
        src/cpp/view_scilab/libsciscicos_algo_la-ScsAdapter.lo \
        src/cpp/view_scilab/libsciscicos_algo_la-StateAdapter.lo \
        src/cpp/view_scilab/libsciscicos_algo_la-TextAdapter.lo
@@ -882,6 +884,7 @@ src/cpp/view_scilab/DiagramAdapter.cpp \
 src/cpp/view_scilab/GraphicsAdapter.cpp \
 src/cpp/view_scilab/LinkAdapter.cpp \
 src/cpp/view_scilab/ModelAdapter.cpp \
+src/cpp/view_scilab/ParamsAdapter.cpp \
 src/cpp/view_scilab/ScsAdapter.cpp \
 src/cpp/view_scilab/StateAdapter.cpp \
 src/cpp/view_scilab/TextAdapter.cpp
@@ -1423,6 +1426,9 @@ src/cpp/view_scilab/libsciscicos_algo_la-LinkAdapter.lo:  \
 src/cpp/view_scilab/libsciscicos_algo_la-ModelAdapter.lo:  \
        src/cpp/view_scilab/$(am__dirstamp) \
        src/cpp/view_scilab/$(DEPDIR)/$(am__dirstamp)
+src/cpp/view_scilab/libsciscicos_algo_la-ParamsAdapter.lo:  \
+       src/cpp/view_scilab/$(am__dirstamp) \
+       src/cpp/view_scilab/$(DEPDIR)/$(am__dirstamp)
 src/cpp/view_scilab/libsciscicos_algo_la-ScsAdapter.lo:  \
        src/cpp/view_scilab/$(am__dirstamp) \
        src/cpp/view_scilab/$(DEPDIR)/$(am__dirstamp)
@@ -1933,6 +1939,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@src/cpp/view_scilab/$(DEPDIR)/libsciscicos_algo_la-GraphicsAdapter.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/cpp/view_scilab/$(DEPDIR)/libsciscicos_algo_la-LinkAdapter.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/cpp/view_scilab/$(DEPDIR)/libsciscicos_algo_la-ModelAdapter.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/cpp/view_scilab/$(DEPDIR)/libsciscicos_algo_la-ParamsAdapter.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/cpp/view_scilab/$(DEPDIR)/libsciscicos_algo_la-ScsAdapter.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/cpp/view_scilab/$(DEPDIR)/libsciscicos_algo_la-StateAdapter.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/cpp/view_scilab/$(DEPDIR)/libsciscicos_algo_la-TextAdapter.Plo@am__quote@
@@ -2592,6 +2599,13 @@ src/cpp/view_scilab/libsciscicos_algo_la-ModelAdapter.lo: src/cpp/view_scilab/Mo
 @AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsciscicos_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o src/cpp/view_scilab/libsciscicos_algo_la-ModelAdapter.lo `test -f 'src/cpp/view_scilab/ModelAdapter.cpp' || echo '$(srcdir)/'`src/cpp/view_scilab/ModelAdapter.cpp
 
+src/cpp/view_scilab/libsciscicos_algo_la-ParamsAdapter.lo: src/cpp/view_scilab/ParamsAdapter.cpp
+@am__fastdepCXX_TRUE@  $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsciscicos_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT src/cpp/view_scilab/libsciscicos_algo_la-ParamsAdapter.lo -MD -MP -MF src/cpp/view_scilab/$(DEPDIR)/libsciscicos_algo_la-ParamsAdapter.Tpo -c -o src/cpp/view_scilab/libsciscicos_algo_la-ParamsAdapter.lo `test -f 'src/cpp/view_scilab/ParamsAdapter.cpp' || echo '$(srcdir)/'`src/cpp/view_scilab/ParamsAdapter.cpp
+@am__fastdepCXX_TRUE@  $(AM_V_at)$(am__mv) src/cpp/view_scilab/$(DEPDIR)/libsciscicos_algo_la-ParamsAdapter.Tpo src/cpp/view_scilab/$(DEPDIR)/libsciscicos_algo_la-ParamsAdapter.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     $(AM_V_CXX)source='src/cpp/view_scilab/ParamsAdapter.cpp' object='src/cpp/view_scilab/libsciscicos_algo_la-ParamsAdapter.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsciscicos_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o src/cpp/view_scilab/libsciscicos_algo_la-ParamsAdapter.lo `test -f 'src/cpp/view_scilab/ParamsAdapter.cpp' || echo '$(srcdir)/'`src/cpp/view_scilab/ParamsAdapter.cpp
+
 src/cpp/view_scilab/libsciscicos_algo_la-ScsAdapter.lo: src/cpp/view_scilab/ScsAdapter.cpp
 @am__fastdepCXX_TRUE@  $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsciscicos_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT src/cpp/view_scilab/libsciscicos_algo_la-ScsAdapter.lo -MD -MP -MF src/cpp/view_scilab/$(DEPDIR)/libsciscicos_algo_la-ScsAdapter.Tpo -c -o src/cpp/view_scilab/libsciscicos_algo_la-ScsAdapter.lo `test -f 'src/cpp/view_scilab/ScsAdapter.cpp' || echo '$(srcdir)/'`src/cpp/view_scilab/ScsAdapter.cpp
 @am__fastdepCXX_TRUE@  $(AM_V_at)$(am__mv) src/cpp/view_scilab/$(DEPDIR)/libsciscicos_algo_la-ScsAdapter.Tpo src/cpp/view_scilab/$(DEPDIR)/libsciscicos_algo_la-ScsAdapter.Plo
index 05fbeae..8f8755d 100644 (file)
@@ -13,6 +13,8 @@
 #ifndef UTILITIES_HXX_
 #define UTILITIES_HXX_
 
+#include <iostream>
+
 namespace org_scilab_modules_scicos
 {
 
@@ -21,25 +23,29 @@ namespace org_scilab_modules_scicos
  *
  * The '0' value is used indicate that BaseObject is not handled by the controller.
  */
-typedef unsigned long long ScicosID;
-//struct ScicosID
-//{
-//    ScicosID() : v(0) {}
-//    ScicosID(const ScicosID& u) : v(u.v) {}
-//
-//    inline bool operator<(const ScicosID& u) const
-//    {
-//        return u.v < u.v;
-//    }
-//    inline bool operator==(const ScicosID& u) const
-//    {
-//        return u.v == u.v;
-//    }
-//private:
-//    typedef unsigned long long uid_container_type;
-//    ScicosID(uid_container_type u) : v(u) {}
-//    uid_container_type v;
-//};
+//typedef unsigned long long ScicosID;
+struct ScicosID
+{
+    ScicosID(const ScicosID& u) : v(u.v) {}
+    typedef unsigned long long uid_container_type;
+    ScicosID(uid_container_type u) : v(u) {}
+
+    inline bool operator<(const ScicosID& u) const
+    {
+        return v < u.v;
+    }
+    inline bool operator==(const ScicosID& u) const
+    {
+        return v == u.v;
+    }
+    inline void operator++(int added)
+    {
+        v = v + added;
+    }
+    friend std::ostream& operator<< (std::ostream &out, const ScicosID& u);
+private:
+    uid_container_type v;
+};
 
 /**
  * Return status of get and set
index 4b4ca95..f29ae4f 100644 (file)
@@ -28,6 +28,7 @@
 #include "view_scilab/GraphicsAdapter.hxx"
 #include "view_scilab/LinkAdapter.hxx"
 #include "view_scilab/ModelAdapter.hxx"
+#include "view_scilab/ParamsAdapter.hxx"
 #include "view_scilab/ScsAdapter.hxx"
 #include "view_scilab/StateAdapter.hxx"
 #include "view_scilab/TextAdapter.hxx"
@@ -164,6 +165,14 @@ types::Function::ReturnValue sci_scicos_new(types::typed_list &in, int _iRetCoun
             }
             out.push_back(returnType);
             break;
+        case view_scilab::Adapters::PARAMS_ADAPTER:
+            returnType = alloc_and_set<view_scilab::ParamsAdapter, model::Diagram>(DIAGRAM, type_name, in);
+            if (returnType == 0)
+            {
+                return types::Function::Error;
+            }
+            out.push_back(returnType);
+            break;
         case view_scilab::Adapters::SCS_ADAPTER:
             returnType = alloc_and_set<view_scilab::ScsAdapter, model::Diagram>(DIAGRAM, type_name, in);
             if (returnType == 0)
index 588e9d0..41aabf9 100644 (file)
@@ -263,6 +263,7 @@ lib /DEF:"$(ProjectDir)differential_equations_f_Import.def" /SUBSYSTEM:WINDOWS /
     <ClCompile Include="..\cpp\view_scilab\GraphicsAdapter.cpp" />
     <ClCompile Include="..\cpp\view_scilab\LinkAdapter.cpp" />
     <ClCompile Include="..\cpp\view_scilab\ModelAdapter.cpp" />
+    <ClCompile Include="..\cpp\view_scilab\ParamsAdapter.cpp" />
     <ClCompile Include="..\cpp\view_scilab\ScsAdapter.cpp" />
     <ClCompile Include="..\cpp\view_scilab\StateAdapter.cpp" />
     <ClCompile Include="..\cpp\view_scilab\TextAdapter.cpp" />
@@ -333,6 +334,7 @@ lib /DEF:"$(ProjectDir)differential_equations_f_Import.def" /SUBSYSTEM:WINDOWS /
     <ClInclude Include="..\cpp\view_scilab\GraphicsAdapter.hxx" />
     <ClInclude Include="..\cpp\view_scilab\LinkAdapter.hxx" />
     <ClInclude Include="..\cpp\view_scilab\ModelAdapter.hxx" />
+    <ClInclude Include="..\cpp\view_scilab\ParamsAdapter.hxx" />
     <ClInclude Include="..\cpp\view_scilab\ScsAdapter.hxx" />
     <ClInclude Include="..\cpp\view_scilab\StateAdapter.hxx" />
     <ClInclude Include="..\cpp\view_scilab\TextAdapter.hxx" />
index 5d5746a..9d7d497 100644 (file)
     <ClCompile Include="..\..\sci_gateway\cpp\sci_scicos_new.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
+    <ClCompile Include="..\cpp\view_scilab\ParamsAdapter.cpp">
+      <Filter>Source Files\MVC\view_scilab</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="copyvarfromlistentry.h">
     <ClInclude Include="..\cpp\view_scilab\StateAdapter.hxx">
       <Filter>Header Files\MVC\view_scilab</Filter>
     </ClInclude>
+    <ClInclude Include="..\cpp\view_scilab\ParamsAdapter.hxx">
+      <Filter>Header Files\MVC\view_scilab</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <None Include="Dynamic_link_Import.def">
index b5fdfe2..52ae3f9 100644 (file)
@@ -29,6 +29,11 @@ LoggerView::~LoggerView()
 {
 }
 
+std::ostream& operator<< (std::ostream &out, const ScicosID& u)
+{
+    return out << u.v;
+}
+
 // generated with :
 // awk ' $2 == "//!<" {sub(",","", $1); print "case " $1 ":\n    os << \"" $1 "\";\n    break;" }' ~/work/branches/YaSp/scilab/modules/scicos/includes/utilities.hxx
 
@@ -71,7 +76,7 @@ static std::ostream& operator<<(std::ostream& os, kind_t k)
     }
     return os;
 }
-;
+
 
 static std::ostream& operator<<(std::ostream& os, object_properties_t p)
 {
index 20d0ca6..e54a42e 100644 (file)
@@ -27,27 +27,67 @@ namespace org_scilab_modules_scicos
 namespace model
 {
 
+/**
+ * Scilab data that can be passed to the simulator and simulation functions.
+ *
+ * This used the raw scicos-sim encoding to avoid any conversion out of the model.
+ */
+struct list_t
+{
+    // re-use the scicos sim encoding
+    int n;
+    int* sz;
+    int* typ;
+    void** data;
+};
+
 struct Parameter
 {
-    // FIXME: list the possible parameters kind, name, and so on
-    double foo;
+    std::vector<double> rpar;
+    std::vector<int> ipar;
+    list_t opar;
 };
 
-// FIXME add more values there
-enum SchedulingProperties
+struct State
+{
+    std::vector<double> state;
+    std::vector<int> dstate;
+    list_t odstate;
+};
+
+/**
+ * Mask list for all possible block scheduling descriptor from the simulator point of view.
+ *
+ * Examples:
+ *  * CONST_m == 0
+ *  * SUMMATION == DEP_U
+ *  * CLR == DEP_T
+ *  * SWITCH_f == DEP_U & DEP_T
+ */
+enum dep_ut_t
 {
     DEP_U       = 1 << 0, //!< y=f(u)
     DEP_T       = 1 << 1, //!< y=f(x)
-    BLOCKTYPE_H = 1 << 2, //!< y=f(u) but depends on t (if then else block)
+};
+
+enum blocktype_t
+{
+    BLOCKTYPE_C = 'c', //!< N/A ; dummy value used to represent a 'c' blocktype (eg. not 'd')
+    BLOCKTYPE_D = 'd', //!< N/A ; dummy value used to represent a 'd' blocktype (eg. not 'c')
+    BLOCKTYPE_H = 'h', //!< N/A ; used to represent blocks composed by blocks
+    BLOCKTYPE_L = 'l', //!< synchronization block ; ifthenelse and eselect
+    BLOCKTYPE_M = 'm', //!< memorization block ; see the Scicos original paper
+    BLOCKTYPE_X = 'x', //!< derivable block without state ; these blocks will be treated as if they contains a state.
+    BLOCKTYPE_Z = 'z', //!< zero-crossing block ; see the Scicos original paper.
 };
 
 struct Descriptor
 {
     std::string functionName;
-    int functionApi;
+    char functionApi;
 
-    // FIXME: should encode all possible values for dep_ut and blocktype
-    int schedulingProperties;
+    char dep_ut;            //!< dep_ut_t masked value
+    char blocktype;         //!< one of blocktype_t value
 };
 
 class Block: public BaseObject
@@ -143,14 +183,14 @@ private:
         this->out = out;
     }
 
-    const Parameter& getParameters() const
+    const Parameter& getParameter() const
     {
-        return parameters;
+        return parameter;
     }
 
-    void setParameters(const Parameter& parameters)
+    void setParameter(const Parameter& parameter)
     {
-        this->parameters = parameters;
+        this->parameter = parameter;
     }
 
     ScicosID getParentBlock() const
@@ -215,7 +255,8 @@ private:
     std::vector<ScicosID> ein;
     std::vector<ScicosID> eout;
 
-    Parameter parameters;
+    Parameter parameter;
+    State state;
 
     /**
      * SuperBlock: the blocks, links and so on contained into this block
index 0158411..574a852 100644 (file)
@@ -25,16 +25,21 @@ namespace model
 
 struct SimulationConfig
 {
-    double final_time;
-
-    // FIXME: add more properties there
+    double final_time;          //!< Final simulation time.
+    double absolute_tolerance;  //!< Integrator absolute tolerance for the numerical solver.
+    double relative_tolerance;  //!< Integrator relative tolerance for the numerical solver.
+    double time_tolerance;      //!< Tolerance on time.
+    double delta_t;             //!< Maximum integration time interval.
+    double delta_h;             //!< Maximum step interval.
+    double realtime_scale;      //!< Real-time scaling; the value 0 corresponds to no real-time scaling.
+    double solver;              //!< Current numerical solver.
 };
 
 class Diagram: public BaseObject
 {
+private:
     friend class ::org_scilab_modules_scicos::Model;
 
-private:
     Diagram() : BaseObject(DIAGRAM) {};
     Diagram(const Diagram& o)  : BaseObject(DIAGRAM) {};
     ~Diagram() {}
@@ -49,6 +54,16 @@ private:
         this->children = children;
     }
 
+    const std::vector<std::string>& getContext() const
+    {
+        return context;
+    }
+
+    void setContext(const std::vector<std::string>& context)
+    {
+        this->context = context;
+    }
+
     const std::vector<Datatype*>& getDatatypes() const
     {
         return datatypes;
@@ -69,11 +84,35 @@ private:
         this->properties = properties;
     }
 
+    const std::string& getTitle() const
+    {
+        return title;
+    }
+
+    void setTitle(const std::string& title)
+    {
+        this->title = title;
+    }
+
+    const std::string& getVersion() const
+    {
+        return version;
+    }
+
+    void setVersion(const std::string& version)
+    {
+        this->version = version;
+    }
+
 private:
+    std::string title;
     SimulationConfig properties;
+    std::vector<std::string> context;
 
     std::vector<ScicosID> children;
     std::vector<Datatype*> datatypes;
+
+    std::string version;
 };
 
 } /* namespace model */
index 46fce80..554edda 100644 (file)
@@ -20,6 +20,7 @@
 #include "GraphicsAdapter.hxx"
 #include "LinkAdapter.hxx"
 #include "ModelAdapter.hxx"
+#include "ParamsAdapter.hxx"
 #include "StateAdapter.hxx"
 #include "TextAdapter.hxx"
 
@@ -51,6 +52,7 @@ Adapters::Adapters()
     adapters.push_back(adapter_t(view_scilab::GraphicsAdapter::getSharedTypeStr(), GRAPHIC_ADAPTER));
     adapters.push_back(adapter_t(view_scilab::LinkAdapter::getSharedTypeStr(), LINK_ADAPTER));
     adapters.push_back(adapter_t(view_scilab::ModelAdapter::getSharedTypeStr(), MODEL_ADAPTER));
+    adapters.push_back(adapter_t(view_scilab::ParamsAdapter::getSharedTypeStr(), PARAMS_ADAPTER));
     adapters.push_back(adapter_t(view_scilab::StateAdapter::getSharedTypeStr(), STATE_ADAPTER));
     adapters.push_back(adapter_t(view_scilab::TextAdapter::getSharedTypeStr(), TEXT_ADAPTER));
 
index f88db1d..e903cbf 100644 (file)
@@ -37,6 +37,7 @@ public:
         GRAPHIC_ADAPTER,    //!< \see view_scilab::GraphicAdapter
         LINK_ADAPTER,       //!< \see view_scilab::LinkAdapter
         MODEL_ADAPTER,      //!< \see view_scilab::ModelAdapter
+        PARAMS_ADAPTER,    //!< \see view_scilab::ParamsAdapter
         SCS_ADAPTER,        //!< \see view_scilab::ScsAdapter
         STATE_ADAPTER,      //!< \see view_scilab::StateAdapter
         TEXT_ADAPTER,       //!< \see view_scilab::TextAdapter
index 9f46b05..cc2a3c0 100644 (file)
  */
 
 #include <string>
+#include <sstream>
 
 #include "internal.hxx"
 #include "list.hxx"
+#include "string.hxx"
 #include "types.hxx"
 #include "user.hxx"
 
 #include "Controller.hxx"
 #include "DiagramAdapter.hxx"
+#include "ParamsAdapter.hxx"
+
+extern "C" {
+#include "version.h"
+}
 
 namespace org_scilab_modules_scicos
 {
 namespace view_scilab
 {
 
+struct props
+{
+
+    static types::InternalType* get(const DiagramAdapter& adaptor)
+    {
+
+        return new ParamsAdapter(adaptor.getAdaptee());
+    }
+
+    static bool set(DiagramAdapter& adaptor, types::InternalType* v)
+    {
+        if (v->getType() == types::InternalType::ScilabUserType
+                && v->getShortTypeStr() == ParamsAdapter::getSharedTypeStr())
+        {
+            ParamsAdapter* props = v->getAs<ParamsAdapter>();
+            adaptor.setAdaptee(props->getAdaptee());
+            return true;
+        }
+        return false;
+    }
+};
+
+struct objs
+{
+
+    static types::InternalType* get(const DiagramAdapter& adaptor)
+    {
+
+        return 0;
+    }
+
+    static bool set(DiagramAdapter& adaptor, types::InternalType* v)
+    {
+        return false;
+    }
+};
+
+struct version
+{
+
+    static types::InternalType* get(const DiagramAdapter& adaptor)
+    {
+        std::stringstream str;
+        str << SCI_VERSION_MAJOR << '.' << SCI_VERSION_MINOR << '.' << SCI_VERSION_MAINTENANCE;
+
+        return new types::String(str.str().c_str());
+    }
+
+    static bool set(DiagramAdapter& adaptor, types::InternalType* v)
+    {
+        //FIXME: handle version upgrade of the whole model
+        return true;
+    }
+};
+
+struct contrib
+{
+
+    static types::InternalType* get(const DiagramAdapter& adaptor)
+    {
+        return 0;
+    }
+
+    static bool set(DiagramAdapter& adaptor, types::InternalType* v)
+    {
+        return false;
+    }
+};
+
 template<> property<DiagramAdapter>::props_t property<DiagramAdapter>::fields = property<DiagramAdapter>::props_t();
 
 DiagramAdapter::DiagramAdapter(const DiagramAdapter& o) :
-    BaseAdapter<DiagramAdapter, org_scilab_modules_scicos::model::Diagram>(o) {}
+    BaseAdapter<DiagramAdapter, org_scilab_modules_scicos::model::Diagram>(o), contrib(o.contrib) {}
 
 DiagramAdapter::DiagramAdapter(org_scilab_modules_scicos::model::Diagram* o) :
-    BaseAdapter<DiagramAdapter, org_scilab_modules_scicos::model::Diagram>(o)
+    BaseAdapter<DiagramAdapter, org_scilab_modules_scicos::model::Diagram>(o), contrib(0)
 {
     if (property<DiagramAdapter>::properties_has_not_been_set())
     {
-        // FIXME: add some properties
+        property<DiagramAdapter>::fields.reserve(4);
+        property<DiagramAdapter>::add_property(L"props", &props::get, &props::set);
+        property<DiagramAdapter>::add_property(L"objs", &objs::get, &objs::set);
+        property<DiagramAdapter>::add_property(L"version", &version::get, &version::set);
+        property<DiagramAdapter>::add_property(L"contrib", &contrib::get, &contrib::set);
     }
 }
 
@@ -58,5 +138,15 @@ std::wstring DiagramAdapter::getShortTypeStr()
     return getSharedTypeStr();
 }
 
+types::InternalType* DiagramAdapter::getContrib() const
+{
+    return contrib;
+}
+
+void DiagramAdapter::setContrib(types::InternalType* contrib)
+{
+    this->contrib = contrib;
+}
+
 } /* view_scilab */
 } /* namespace org_scilab_modules_scicos */
index 6c5529e..bf95497 100644 (file)
@@ -16,8 +16,8 @@
 #include <string>
 #include <sstream>
 
+#include "utilities.hxx"
 #include "BaseAdapter.hxx"
-
 #include "model/Diagram.hxx"
 
 namespace org_scilab_modules_scicos
@@ -40,6 +40,12 @@ public:
     bool toString(std::wostringstream& ostr);
     std::wstring getTypeStr();
     std::wstring getShortTypeStr();
+
+    types::InternalType* getContrib() const;
+    void setContrib(types::InternalType* contrib);
+
+private:
+    types::InternalType* contrib;
 };
 
 } /* view_scilab */
diff --git a/scilab/modules/scicos/src/cpp/view_scilab/ParamsAdapter.cpp b/scilab/modules/scicos/src/cpp/view_scilab/ParamsAdapter.cpp
new file mode 100644 (file)
index 0000000..5a58cc4
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ *  Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ *  Copyright (C) 2014-2014 - Scilab Enterprises - Clement DAVID
+ *
+ *  This file must be used under the terms of the CeCILL.
+ *  This source file is licensed as described in the file COPYING, which
+ *  you should have received as part of this distribution.  The terms
+ *  are also available at
+ *  http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+
+#include "ParamsAdapter.hxx"
+
+namespace org_scilab_modules_scicos
+{
+namespace view_scilab
+{
+
+template<> property<ParamsAdapter>::props_t property<ParamsAdapter>::fields = property<ParamsAdapter>::props_t();
+
+ParamsAdapter::ParamsAdapter(const ParamsAdapter& o) :
+    BaseAdapter<ParamsAdapter, org_scilab_modules_scicos::model::Diagram>(o) {}
+
+ParamsAdapter::ParamsAdapter(org_scilab_modules_scicos::model::Diagram* o) :
+    BaseAdapter<ParamsAdapter, org_scilab_modules_scicos::model::Diagram>(o)
+{
+    if (property<ParamsAdapter>::properties_has_not_been_set())
+    {
+        // FIXME: add some properties
+    }
+}
+
+ParamsAdapter::~ParamsAdapter()
+{
+}
+
+bool ParamsAdapter::toString(std::wostringstream& ostr)
+{
+    ostr << L"ParamsAdapter.hxx: Dunno what to display there";
+    return true;
+}
+
+std::wstring ParamsAdapter::getTypeStr()
+{
+    return getSharedTypeStr();
+}
+std::wstring ParamsAdapter::getShortTypeStr()
+{
+    return getSharedTypeStr();
+}
+
+} /* namespace view_scilab */
+} /* namespace org_scilab_modules_scicos */
diff --git a/scilab/modules/scicos/src/cpp/view_scilab/ParamsAdapter.hxx b/scilab/modules/scicos/src/cpp/view_scilab/ParamsAdapter.hxx
new file mode 100644 (file)
index 0000000..078e105
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ *  Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ *  Copyright (C) 2014-2014 - Scilab Enterprises - Clement DAVID
+ *
+ *  This file must be used under the terms of the CeCILL.
+ *  This source file is licensed as described in the file COPYING, which
+ *  you should have received as part of this distribution.  The terms
+ *  are also available at
+ *  http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+
+#ifndef PARAMSADAPTER_HXX_
+#define PARAMSADAPTER_HXX_
+
+#include <string>
+#include <sstream>
+
+#include "BaseAdapter.hxx"
+
+#include "model/Diagram.hxx"
+
+namespace org_scilab_modules_scicos
+{
+namespace view_scilab
+{
+
+class ParamsAdapter : public BaseAdapter<ParamsAdapter, org_scilab_modules_scicos::model::Diagram>
+{
+public:
+    ParamsAdapter(const ParamsAdapter& o);
+    ParamsAdapter(org_scilab_modules_scicos::model::Diagram* o);
+    ~ParamsAdapter();
+
+    static const std::wstring getSharedTypeStr()
+    {
+        return L"params";
+    }
+
+    bool toString(std::wostringstream& ostr);
+    std::wstring getTypeStr();
+    std::wstring getShortTypeStr();
+};
+
+} /* namespace view_scilab */
+} /* namespace org_scilab_modules_scicos */
+
+#endif /* PARAMSADAPTER_HXX_ */