OSDN Git Service

now development for support of the variable do
[liveml/LiveML.git] / src / livemlrunner.h
index 3ca0667..39bf519 100644 (file)
@@ -1,5 +1,4 @@
-/**
- * LiveML - LiveML is screen(graphic) controling library using XML.
+/** * LiveML - LiveML is screen(graphic) controling library using XML.
  *
  * LGPL License
  * Copyright (C) 2010 Nothan
 #include "list.hpp"
 #include "bool_list.hpp"
 
+class LiveMLRunner;
+
 class LMLParameter : public Parameter
 {
 public:
-  float getFloat(size_t);
-  int getInteger(size_t);
-  const char* getString(size_t);
+  float getFloat(size_t, LiveMLRunner &);
+  int getInteger(size_t, LiveMLRunner &);
+  int getFixedFloat(size_t, LiveMLRunner &);
+  const char* getText(size_t, LiveMLRunner &);
+};
+
+class LMLVariable
+{
+public:
+  list<fixed_float> numericList;
+
+  void setFixedFloat(variable_size id, fixed_float v)
+  {
+/*
+    list_item<fixed_float> *variable = (list_item<fixed_float>*)numericList.front();
+    fixed_float &set = *(fixed_float*)(variable + VAR_LOCAL_ID(id));
+    set = v;
+*/
+  }
+
+  void setString(variable_size id, const char *v)
+  {
+  }
+
+  fixed_float getFixedFloat(variable_size id)
+  {
+    return 0;
+/*
+    list_item<fixed_float> *variable = (list_item<fixed_float>*)numericList.front();
+
+    return *(fixed_float*)(variable + VAR_LOCAL_ID(id));
+*/
+  }
+
+  const char* getString(variable_size id)
+  {
+    return "";
+  }
 };
 
 struct LMLObject
@@ -50,6 +86,10 @@ public:
   list<Tag*> currentTagList;
   unsigned int waitCounter;
   list<unsigned int> repeatCounter;
+  // local variable
+  LMLVariable localVariable;
+  // member variable
+  LMLVariable memberVariable;
 
   void init()
   {
@@ -57,26 +97,50 @@ public:
     waitCounter = 0;
   }
 
+  void setVariableAllocator(list_allocator<fixed_float> *alloc)
+  {
+    localVariable.numericList.allocator(alloc);
+    memberVariable.numericList.allocator(alloc);
+  }
+
   bool setAction(ActionParser *action)
   {
+#ifdef DEBUG
+    printf("LMLObject::setAction(ActionParser*) begin.\n");
+#endif
     *currentActionList.push_back() = action;
     if (action == NULL) return false;
     *currentTagList.push_back() = action->tag;
 
+#ifdef DEBUG
+    printf("LMLObject::setAction(ActionParser*) end.\n");
+#endif
     return true;
   }
   bool setAction(action_type type)
   {
+#ifdef DEBUG
+    printf("LMLObject::setAction(%d) begin.\n", type);
+#endif
     ActionParser *action = parser->actionContainer.getAction(type);
     if (action == NULL) return false;
 
     setAction(action);
+#ifdef DEBUG
+    printf("LMLObject::setAction(%d) end.\n", type);
+#endif
     return true;
   }
   bool setActionByName(const char *name)
   {
+#ifdef DEBUG
+    printf("LMLObject::setActionByName(%s) begin.\n", name);
+#endif
     action_type type = parser->actionContainer.getActionType(name);
+#ifdef DEBUG
     printf("find %s => %d\n", name, type);
+    printf("LMLObject::setActionByName(%s) end.\n", name);
+#endif
     return setAction(type);
   }
 };
@@ -100,24 +164,29 @@ class LiveMLRunner
   LMLSceneObject _scene;
   list<LMLActorObject> _actorList;
   LMLActorObject *_currentActor;
+  LMLObject *_currentObject;
   LMLObject *_focusObject;
   vector<FuncPtr> _commandFuncs;
   bool_list _eventFlag;
   list_allocator<ActionParser*> _actionAllocator;
   list_allocator<Tag*> _tagAllocator;
   list_allocator<unsigned int> _repeatAllocator;
+  list_allocator<fixed_float> _numericVariableAllocator;
 
 public:
   LiveMLParser *parser;
+  // global variable
+  LMLVariable variable;
+
+  LiveMLRunner(LiveMLParser*);
+  ~LiveMLRunner();
+
   bool registerCommand(
     const char*,
     bool (*)(LMLParameter&, LMLObject&, LiveMLRunner&),
     bool (*)(LMLParameter&, LMLObject&, LiveMLRunner&) = NULL
   );
 
-  LiveMLRunner(LiveMLParser*);
-  ~LiveMLRunner();
-
   void setMaxActors(size_t);
   LMLSceneObject* setScene(const char*);
   LMLActorObject* addActor(const char*);
@@ -125,6 +194,9 @@ public:
   void setCurrentActor(LMLActorObject *obj) { _currentActor = obj; }
   LMLActorObject* getCurrentActor(void) { return _currentActor; }
 
+  void setCurrentObject(LMLObject *obj) { _currentObject = obj; }
+  LMLObject* getCurrentObject(void) { return _currentObject; }
+
   void setFocusObject(LMLObject* obj) { _focusObject = obj; }
   LMLObject* getFocusObject(void) { return  _focusObject; }
 
@@ -139,6 +211,7 @@ public:
   bool runObjectAction(LMLObject&);
   bool runObject(LMLObject&);
   void run(void);
+  LMLVariable* getVariable(variable_size);
 
   static fixed_float variableNumericDecoder(variable_size, void*);
   static const char* variableStringDecoder(variable_size, void*);