Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifndef INNOVATION_ENGINE_BASIC_TREE_H
- #define INNOVATION_ENGINE_BASIC_TREE_H
- #include <deque>
- #include <ORE\Retainable Container.h>
- // std::deque chosen for general-purpose capabilities and efficiencies.
- #define DEF_SEQUENTIAL_CONTAINER std::deque
- namespace ie
- {
- enum NodeType
- {
- Tree_Node = 1,
- Tree_Split = 2,
- Tree_Branch = 6, // Tree_Branch has 2's bit ON
- Tree_Root = 10, // Tree_Root has 2's bit ON You can still check for exact values, but if you just
- // want something with children then check for Split's bit
- Tree_Mask = 0xFF // Mask of the NodeType variable that is being used by the system itself, feel free to use
- // the other bits if you want to
- };
- // Keeping inheritance in mind, all members are typed using STL-style
- // naming and are prefixed with an underscore and an abbreviation
- // of the parent class name to keep down on intellisense clutter.
- class CBasicTreeObject
- {
- public:
- NodeType _bto_type;
- virtual ~CBasicTreeObject ()
- {
- }
- };
- class CBasicSequentialTreeSplit;
- class CBasicSequentialTreeNode
- : public CBasicTreeObject
- {
- public:
- CBasicSequentialTreeNode * _bstn_next, * _bstn_previous;
- CBasicSequentialTreeSplit * _bstn_parent;
- CBasicSequentialTreeNode (CBasicSequentialTreeNode* next = NULL, CBasicSequentialTreeNode* previous = NULL, CBasicSequentialTreeSplit* parent = NULL)
- : _bstn_next (next), _bstn_previous (previous), _bstn_parent (parent)
- {
- _bto_type = Tree_Node;
- }
- CBasicSequentialTreeNode (const CBasicSequentialTreeNode& o)
- : _bstn_next (o._bstn_next), _bstn_previous (o._bstn_previous), _bstn_parent (o._bstn_parent)
- {
- _bto_type = Tree_Node;
- }
- virtual ~CBasicSequentialTreeNode (){}
- };
- // SEQUENTIAL CLASS DEFINITIONS
- // Some object that can have children (bad name I know, nothing else really works though.)
- class CBasicSequentialTreeSplit
- {
- public:
- // You'll have to handle the deletion of the children yourself
- ie::CRetainablePtr <DEF_SEQUENTIAL_CONTAINER <CBasicSequentialTreeNode *>> _bsts_children;
- CBasicSequentialTreeSplit ()
- : _bsts_children (new DEF_SEQUENTIAL_CONTAINER <CBasicSequentialTreeNode *>)
- {
- }
- CBasicSequentialTreeSplit (const CBasicSequentialTreeSplit& o)
- : _bsts_children (o._bsts_children)
- {
- }
- virtual ~CBasicSequentialTreeSplit () {}
- };
- // A branch, specifically
- class CBasicSequentialTreeBranch
- : public CBasicSequentialTreeNode, public CBasicSequentialTreeSplit
- {
- public:
- CBasicSequentialTreeBranch (CBasicSequentialTreeNode* next = NULL, CBasicSequentialTreeNode* previous = NULL, CBasicSequentialTreeSplit* parent = NULL)
- : CBasicSequentialTreeNode (next, previous, parent)
- {
- _bto_type = Tree_Branch;
- }
- virtual ~CBasicSequentialTreeBranch () {}
- };
- // A tree, specifically
- class CBasicSequentialTree
- : public CBasicTreeObject, public CBasicSequentialTreeSplit
- {
- public:
- CBasicSequentialTree ()
- {
- _bto_type = Tree_Root;
- }
- virtual ~CBasicSequentialTree () {}
- };
- // TYPE DEFINITIONS
- typedef DEF_SEQUENTIAL_CONTAINER <CBasicSequentialTreeNode *> SequentialTreeContainer;
- typedef DEF_SEQUENTIAL_CONTAINER <CBasicSequentialTreeNode *>::iterator SequentialTreeIterator;
- }
- #endif
Advertisement
Add Comment
Please, Sign In to add comment