runTree.h
Ir a la documentación de este archivo.
1 //runTree.h
2 //-------------------------------------------------------------------------------------------
3 /*
4  * Fco. Javier Bohórquez Ogalla
5  * 75766599-E
6  * Puerto Real (Cádiz)
7  * powersgame@gmail.com
8  */
9 //-------------------------------------------------------------------------------------------
10 /*
11  * This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 2 of the License, or
14  * (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software
23  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
24  * MA 02110-1301, USA.
25  */
26 //-------------------------------------------------------------------------------------------
57 //-------------------------------------------------------------------------------------------
58 #ifndef _RUN_TREE_RUNTREE_
59 #define _RUN_TREE_RUNTREE_
60 //-------------------------------------------------------------------------------------------
61 
62 //-------------------------------------------------------------------------------------------
63 #include <string>
64 #include <vector>
65 #include <map>
66 #include <iostream>
67 
68 typedef NUMTYPE num;
69 typedef REFCTYPE refC;
70 
71 using namespace std;
72 //-------------------------------------------------------------------------------------------
73 
74 //-------------------------------------------------------------------------------------------
123 class runNode {
124  public:
128  runNode (string str);
132  runNode ();
144  virtual void run () = 0;
148  virtual void addRef ();
153  virtual void rmRef ();
168  static bool compare(runNode *node1, runNode *node2, int op = 0);
174  virtual bool is_print () const;
180  virtual bool is_runlist () const;
186  virtual bool is_string () const;
192  string getPtrString ();
193 #if JSON==1
194 
204  string toJson (string name, string type, runNode** rel = NULL, string* relname = NULL, int rel_n = 0, string value = "", string key = "");
214  string toJson (string name, string type, runNode** rel, string* relname, int rel_n, num value);
215  string json;
216 #endif
217  virtual bool to_bool ();
218  virtual num to_num ();
219  virtual string to_str ();
220  virtual ~runNode ();
221  refC ref_count_;
222  bool isprivate_;
223 
224 };
225 //-------------------------------------------------------------------------------------------
226 
227 //-------------------------------------------------------------------------------------------
235 struct cmp_runNode {
240  bool operator()(runNode *node1, runNode *node2);
241 
242 };
243 //-------------------------------------------------------------------------------------------
244 
245 //-------------------------------------------------------------------------------------------
254 class printableNode: public runNode {
255  public:
260  virtual string print () const = 0;
261 };
262 //-------------------------------------------------------------------------------------------
263 
264 //-------------------------------------------------------------------------------------------
279 class refNode : public printableNode {
280  public:
285  refNode();
290  refNode(string str);
295  refNode(runNode* data);
300  refNode (refNode *a);
305  void setRef (runNode* node );
310  runNode* getRef () const;
315  runNode* &getRef ();
319  void run ();
324  void rmRef ();
328  void del ();
333  string strvalue ();
338  int numvalue ();
343  bool boolvalue ();
348  string print () const;
353  void setKey (string s);
358  string getKey ();
359  private:
360  string keyvalue_;
361  runNode * refSymbol_;
362 };
363 //-------------------------------------------------------------------------------------------
364 
365 //-------------------------------------------------------------------------------------------
380  public:
384  objectTypeNode ();
390  runNode* getMethod (runNode* key);
396  refNode* getMethodRef (runNode* key);
402  virtual runNode * getClass ();
407  virtual void setClass (runNode * c);
408  protected:
409  runNode * custom_class_;
410 };
411 //-------------------------------------------------------------------------------------------
412 
413 //-------------------------------------------------------------------------------------------
414 #endif
415 //-------------------------------------------------------------------------------------------
416 
417 //-------------------------------------------------------------------------------------------
418 //Fco. Javier Bohórquez Ogalla
419 
Definition: runTree.h:235
Nodo tipo de objeto.
Definition: runTree.h:379
Nodos imprimible.
Definition: runTree.h:254
Nodo ejecutable.
Definition: runTree.h:123
Nodo referencia.
Definition: runTree.h:279