![]() |
libsesstype
2.0.0
Library for Session Types programming.
|
00001 #ifndef SESSTYPE__NODE__CHOICE_H__ 00002 #define SESSTYPE__NODE__CHOICE_H__ 00003 00004 #include "sesstype/msg.h" 00005 #include "sesstype/node.h" 00006 #include "sesstype/role.h" 00007 #include "sesstype/node/block.h" 00008 00009 #ifdef __cplusplus 00010 namespace sesstype { 00011 #endif 00012 00013 #ifdef __cplusplus 00014 00017 template <class BaseNode, class RoleType, class MessageType, class VisitorType> 00018 class ChoiceNodeTmpl : public BlockNodeTmpl<BaseNode, RoleType, MessageType, VisitorType> { 00019 RoleType *at_; 00020 00021 public: 00023 ChoiceNodeTmpl() 00024 : BlockNodeTmpl<BaseNode, RoleType, MessageType, VisitorType>(ST_NODE_CHOICE), 00025 at_() { } 00026 00029 ChoiceNodeTmpl(RoleType *at) 00030 : BlockNodeTmpl<BaseNode, RoleType, MessageType, VisitorType>(ST_NODE_CHOICE), 00031 at_(at) { } 00032 00034 ChoiceNodeTmpl(const ChoiceNodeTmpl &node) 00035 : BlockNodeTmpl<BaseNode, RoleType, MessageType, VisitorType>(node), 00036 at_(node.at_) { } 00037 00039 ~ChoiceNodeTmpl() override 00040 { 00041 delete at_; 00042 } 00043 00045 ChoiceNodeTmpl *clone() const override 00046 { 00047 return new ChoiceNodeTmpl(*this); 00048 } 00049 00051 void set_at(RoleType *at) 00052 { 00053 delete at_; 00054 at_ = at->clone(); 00055 } 00056 00058 RoleType *at() const 00059 { 00060 return at_; 00061 } 00062 00064 void add_choice(BaseNode *choice) 00065 { 00066 this->append_child(choice); 00067 } 00068 00069 void accept(VisitorType &v) override; 00070 }; 00071 00072 using ChoiceNode = ChoiceNodeTmpl<Node, Role, MsgSig, util::NodeVisitor>; 00073 #endif // __cplusplus 00074 00075 #ifdef __cplusplus 00076 extern "C" { 00077 #endif 00078 00079 st_node *st_mk_choice_node_init(); 00080 00081 st_node *st_mk_choice_node(st_role *at); 00082 00083 st_role *st_choice_node_get_at(st_node *const node); 00084 00085 st_node *st_choice_node_set_at(st_node *const node, st_role *at); 00086 00087 #ifdef __cplusplus 00088 } // extern "C" 00089 #endif 00090 00091 #ifdef __cplusplus 00092 } // namespace sesstype 00093 #endif 00094 00095 #endif//SESSTYPE__NODE__CHOICE_H__