Inferno
0.2
|
00001 #ifndef NODE_HPP 00002 #define NODE_HPP 00003 00004 #include "common/common.hpp" 00005 #include "common/shared_ptr.hpp" 00006 #include "specialise_oostd.hpp" 00007 #include "itemise.hpp" 00008 #include "type_info.hpp" 00009 #include "clone.hpp" 00010 #include "common/magic.hpp" 00011 #include "match.hpp" 00012 00013 #define FINAL_FUNCTION(F) virtual bool IsFinal() { return (F); } 00014 00015 // Mix together the bounce classes for the benefit of the tree 00016 // TODO figure out how to enforce finality in NODE_FUNCTIONS_FINAL 00017 #define NODE_FUNCTIONS ITEMISE_FUNCTION MATCHER_FUNCTION CLONE_FUNCTION FINAL_FUNCTION(false) 00018 #define NODE_FUNCTIONS_FINAL ITEMISE_FUNCTION MATCHER_FUNCTION CLONE_FUNCTION FINAL_FUNCTION(true) 00019 struct NodeBases : Magic, 00020 virtual Traceable, 00021 Matcher, 00022 Itemiser, 00023 Cloner 00024 { 00025 }; 00026 00027 // Base class for all tree nodes and nodes in search/replace 00028 // patterns etc. Convention is to use "struct" for derived 00029 // node classes so that everything is public (inferno tree nodes 00030 // are more like records in a database, they have only minimal 00031 // functionality). Also, all derived structs should contain the 00032 // NODE_FUNCTIONS macro which expands to a few virtual functions 00033 // required for common ("bounced") functionality. Where multiple 00034 // inheritance diamonds arise, Node should be derived virtually 00035 // (we always want the set-restricting model of inheritance in 00036 // the inferno tree node hierarchy). 00037 struct Node : NodeBases 00038 { 00039 NODE_FUNCTIONS 00040 00041 virtual ~Node(){} // be a virtual hierarchy 00042 // Node must be inherited virtually, to allow MI diamonds 00043 // without making Node ambiguous 00044 00045 static string GetInterfaces() { return string(""); } 00046 }; 00047 00048 template<> 00049 struct MakeTreePtr<Node> : TreePtr<Node> 00050 { 00051 MakeTreePtr() : TreePtr<Node>( new Node ) {} 00052 template<typename CP0> 00053 MakeTreePtr(const CP0 &cp0) : TreePtr<Node>( new Node(cp0) ) {} 00054 template<typename CP0, typename CP1> 00055 MakeTreePtr(const CP0 &cp0, const CP1 &cp1) : TreePtr<Node>( new Node(cp0, cp1) ) {} 00056 template<typename CP0, typename CP1, typename CP2> 00057 MakeTreePtr(const CP0 &cp0, const CP1 &cp1, const CP2 &cp2) : TreePtr<Node>( new Node(cp0, cp1, cp2) ) {} 00058 // Add more params as needed... 00059 }; 00060 00061 00062 extern void GenericsTest(); 00063 00064 #endif