Xcos MVC: implement state / dstate / blocktype
[scilab.git] / scilab / modules / scicos / src / cpp / model / Block.hxx
index 04689a2..acf7f73 100644 (file)
@@ -50,7 +50,7 @@ struct Parameter
 struct State
 {
     std::vector<double> state;
-    std::vector<int> dstate;
+    std::vector<double> dstate;
     list_t odstate;
 };
 
@@ -381,6 +381,67 @@ private:
         return SUCCESS;
     }
 
+    void getSimBlocktype(int& data) const
+    {
+        data = sim.blocktype;
+    }
+
+    update_status_t setSimBlocktype(const int data)
+    {
+        if (data == sim.blocktype)
+        {
+            return NO_CHANGES;
+        }
+
+        switch (data)
+        {
+            case BLOCKTYPE_C:
+            case BLOCKTYPE_D:
+            case BLOCKTYPE_H:
+            case BLOCKTYPE_L:
+            case BLOCKTYPE_M:
+            case BLOCKTYPE_X:
+            case BLOCKTYPE_Z:
+                sim.blocktype = data;
+                break;
+            default:
+                return FAIL;
+        }
+        return SUCCESS;
+    }
+
+    void getState(std::vector<double>& data) const
+    {
+        data = state.state;
+    }
+
+    update_status_t setState(const std::vector<double>& data)
+    {
+        if (data == state.state)
+        {
+            return NO_CHANGES;
+        }
+
+        state.state = data;
+        return SUCCESS;
+    }
+
+    void getDState(std::vector<double>& data) const
+    {
+        data = state.dstate;
+    }
+
+    update_status_t setDState(const std::vector<double>& data)
+    {
+        if (data == state.dstate)
+        {
+            return NO_CHANGES;
+        }
+
+        state.dstate = data;
+        return SUCCESS;
+    }
+
 private:
     ScicosID parentDiagram;
     std::string interfaceFunction;