00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00035 #ifndef PROJECTIONTREENODE_H
00036 #define PROJECTIONTREENODE_H
00037
00038 #include "pathexpression.h"
00039 #include "passiveprojectiontree.h"
00040 #include "outputstreammanip.h"
00041
00054 class ProjectionTreeNode {
00055
00056 public:
00069 ProjectionTreeNode(ProjectionTreeNode * _parent, int _var,
00070 PathExpression * _path, bool _dep, Role * _role,
00071 bool _direct_output);
00072
00076 virtual ~ ProjectionTreeNode();
00077
00090 bool insertNode(int parent_var, int introduced_var,
00091 PathExpression * path, bool dep, Role * role,
00092 bool direct_output);
00093
00100 void print(OutputStream & dos);
00101
00107 inline ProjectionTreeNode *getParent() {
00108 return parent;
00109 } inline int getVar() {
00115 return var;
00116 }
00117
00123 inline PathExpression *getPath() {
00124 return path;
00125 }
00126
00132 inline Role *getRole() {
00133 return role;
00134 }
00135
00141 inline vector < ProjectionTreeNode * >*getChildren() {
00142 return &children;
00143 }
00144
00152 PathExpression *getRootPath();
00153
00161 void getPathsFromRoot(vector < PathExpression * >&paths);
00162
00169 inline bool isRoot() {
00170 return parent == NULL;
00171 }
00172
00179 inline bool isDepNode() {
00180 return dep;
00181 }
00182
00189 inline bool isPosDepNode() {
00190 return role && role->isPosRole();
00191 }
00192
00199 inline bool isDosDepNode() {
00200 return role && role->isDosRole();
00201 }
00202
00208 inline void clearChildren() {
00209 children.clear();
00210 }
00211
00218 void removeUnneededNodes(PassiveProjectionTree * ppt);
00219
00226 void removeRedundantRoles(PassiveProjectionTree * ppt);
00227
00235 void registerToPassiveProjectionTree(PassiveProjectionTree * ppt);
00236
00237 private:
00245 void print(OutputStream & dos, unsigned indents);
00246
00253 void removeSubtreeInclSelf(PassiveProjectionTree * ppt);
00254
00261 void removeSubtreeExclSelf(PassiveProjectionTree * ppt);
00262
00268 void setRedundantRoleSelf();
00269
00274 ProjectionTreeNode *parent;
00275
00281 int var;
00282
00287 PathExpression *path;
00288
00294 bool dep;
00295
00300 Role *role;
00301
00306 vector < ProjectionTreeNode * >children;
00307
00313 bool direct_output;
00314 };
00315
00316 #endif // PROJECTIONTREENODE_H