![]() |
libsesstype
2.0.0
Library for Session Types programming.
|
00001 00005 #ifndef SESSTYPE__PARAMETERISED__CONST_H__ 00006 #define SESSTYPE__PARAMETERISED__CONST_H__ 00007 00008 #ifdef __cplusplus 00009 #include <string> 00010 #endif 00011 00012 #ifdef __cplusplus 00013 namespace sesstype { 00014 namespace parameterised { 00015 #endif 00016 00017 #define ST_CONST_VALUE 1 00018 #define ST_CONST_RANGE 2 00019 #define ST_CONST_SCALABLE 3 00020 00021 #ifdef __cplusplus 00022 00025 class Constant { 00026 std::string name_; 00027 int type_; 00028 00029 public: 00031 virtual ~Constant() { } 00032 00034 std::string name() const 00035 { 00036 return name_; 00037 } 00038 00040 int type() const 00041 { 00042 return type_; 00043 } 00044 00045 protected: 00046 Constant(std::string name, int type) : name_(name), type_(type) { } 00047 }; 00048 00052 class ValueConstant : public Constant { 00053 unsigned int value_; 00054 00055 public: 00059 ValueConstant(std::string name, unsigned int value) 00060 : Constant(name, ST_CONST_VALUE), value_(value) { } 00061 00063 ~ValueConstant() override { } 00064 00066 unsigned int value() const 00067 { 00068 return value_; 00069 } 00070 }; 00071 00075 class BoundedConstant : public Constant { 00076 unsigned int lbound_; 00077 unsigned int ubound_; 00078 00079 public: 00084 BoundedConstant(std::string name, unsigned int lbound, unsigned int ubound) 00085 : Constant(name, ST_CONST_RANGE), lbound_(lbound), ubound_(ubound) { } 00086 00088 ~BoundedConstant() override { } 00089 00091 unsigned int lbound() const 00092 { 00093 return lbound_; 00094 } 00095 00097 unsigned int ubound() const 00098 { 00099 return ubound_; 00100 } 00101 }; 00102 00106 class ScalableConstant : public Constant { 00107 unsigned int lbound_; 00108 00109 public: 00113 ScalableConstant(std::string name, unsigned int lbound) 00114 : Constant(name, ST_CONST_SCALABLE), lbound_(lbound) { } 00115 00117 ~ScalableConstant() override { } 00118 00120 unsigned int lbound() const 00121 { 00122 return lbound_; 00123 } 00124 }; 00125 #endif 00126 00127 #ifdef __cplusplus 00128 extern "C" { 00129 #endif 00130 00131 #ifdef __cplusplus 00132 typedef Constant st_const; 00133 #else 00134 typedef struct Constant st_const; 00135 #endif 00136 00141 st_const *st_mk_val_const(const char *name, int value); 00142 00148 st_const *st_mk_rng_const(const char *name, int lbound, int ubound); 00149 00154 st_const *st_mk_inf_const(const char *name, int lbound); 00155 00158 int st_const_get_type(st_const *const con); 00159 00161 void st_free_const(st_const *con); 00162 00163 #ifdef __cplusplus 00164 } // extern "C" 00165 #endif 00166 00167 #ifdef __cplusplus 00168 } // namespace parameterised 00169 } // namespace sesstype 00170 #endif 00171 00172 #endif // SESSTYPE__PARAMETERISED__CONST_H__