#ifndef DEPTREE_H #define DEPTREE_H #include #include #include #include #include #include "globals.h" class DepTree { typedef std::vector LeafVector; typedef std::map DepTreeVars; typedef std::set NodeVector; typedef std::set CallStack; enum NodeType {NOTDEF,ROOT,SAVE,PRINT,VAR}; typedef struct { const DepTree* root; int exitcode; LeafVector leafs; pthread_mutex_t leaf_mtx; pthread_mutex_t root_mtx; pthread_mutex_t tree_mtx; } thread_params; NodeVector parents; NodeVector childrens; NodeType type; std::string name; ExecExpr exe; int CreateNodeFromVar(const std::string& v, VarType& vars, DepTreeVars& dvars, CallStack& callstack); int CreateNodeFromSP(NodeType list, VarType& vars, ExecExpr& exp, DepTreeVars& dvars); LeafVector FindLeafNodes() const; public: DepTree():type(DepTree::NOTDEF) {} DepTree(const DepTree&) = delete; ~DepTree() { for(auto& i:parents) i->childrens.erase(this); for(auto& i:childrens) { i->parents.erase(this); if(i->parents.size()==0) delete i; } } int CreateTree(ExecType& save, ExecType& print, VarType& vars); int EvaluateTree(unsigned int nthreads); void DumpTree() const; int CheckFunctions() const; friend void* TreeEvaluateM(void* arg); friend void* TreeEvaluate (void* arg); }; #endif