E2AP Abstraction Changes
[ric-app/hw.git] / src / xapp-asn / e2sm / e2sm_subscription.hpp
1 /*
2 ==================================================================================
3
4         Copyright (c) 2019-2020 AT&T Intellectual Property.
5
6    Licensed under the Apache License, Version 2.0 (the "License");
7    you may not use this file except in compliance with the License.
8    You may obtain a copy of the License at
9
10        http://www.apache.org/licenses/LICENSE-2.0
11
12    Unless required by applicable law or agreed to in writing, software
13    distributed under the License is distributed on an "AS IS" BASIS,
14    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15    See the License for the specific language governing permissions and
16    limitations under the License.
17 ==================================================================================
18 */
19 /*
20  * e2sm_subscription.hpp
21  *
22  *  Created on: Jun 30, 2020
23  *      Author: sjana
24  */
25
26 #ifndef XAPP_ASN_REFACTOR_E2SM_SUBSCRIPTION_HPP_
27 #define XAPP_ASN_REFACTOR_E2SM_SUBSCRIPTION_HPP_
28
29
30 #include <errno.h>
31 #include <iostream>
32 #include <vector>
33 #include <sstream>
34 #include <memory>
35 #include <mdclog/mdclog.h>
36
37 #include <E2SM-HelloWorld-EventTriggerDefinition.h>
38 #include <E2SM-HelloWorld-ActionDefinition.h>
39 #include <E2SM-HelloWorld-EventTriggerDefinition-Format1.h>
40 #include <E2SM-HelloWorld-ActionDefinition-Format1.h>
41 #include <HW-TriggerNature.h>
42 #include <RANparameter-Item.h>
43 #include <ProtocolIE-Field.h>
44
45 class HWEventTriggerDefinition {
46 public:
47    HWEventTriggerDefinition(void);
48   ~HWEventTriggerDefinition(void);
49
50   bool encode(unsigned char *, size_t *);
51   std::string  get_error (void) const {return _error_string ;};
52   int get_triggerNature(){return this->_triggerNature;};
53   HWEventTriggerDefinition& set_triggerNature(int trigger){ this->_triggerNature = trigger; return *this;};
54
55 private:
56
57   E2SM_HelloWorld_EventTriggerDefinition_t * _event_trigger; // used for encoding
58   E2SM_HelloWorld_EventTriggerDefinition_Format1_t _event_fmt1;
59   int _triggerNature;
60
61   size_t _errbuf_len = 128;
62   char _errbuf[128];
63   std::string _error_string;
64 };
65
66
67 class HWActionDefinition {
68
69 public:
70   HWActionDefinition(void);
71   ~HWActionDefinition(void);
72   class RANParamIEs{
73
74   private:
75                   long int _param_id;
76               unsigned char _param_name[20];
77               size_t _param_name_size;
78               int _param_test;
79               unsigned char _param_value[20];
80               size_t _param_value_size;
81   public:
82                   RANParamIEs(void):_param_id(0),_param_name_size(0), _param_test(0),_param_value_size(0){};
83                   RANParamIEs& set_param_id(int param_id) {_param_id = param_id; return *this;};
84                   RANParamIEs& set_param_name(std::string param_name) { _param_name_size = strlen(param_name.c_str());
85                                                                                                                            strncpy((char*)_param_name,param_name.c_str(),_param_name_size); return *this;};
86                   RANParamIEs& set_param_test(int param_test) {_param_test = param_test; return *this;};
87                   RANParamIEs& set_param_value(std::string param_value) {_param_value_size = strlen(param_value.c_str());
88                                                                                                                                  strncpy((char*)_param_value,param_value.c_str(),_param_value_size); return *this;};
89
90                   int get_param_id(){return this->_param_id;};
91                   int get_param_test(){return this->_param_test;};
92                   unsigned char* get_param_name(){return this->_param_name;};
93                   int get_param_name_size(){return this->_param_name_size;};
94                   unsigned char* get_param_value(){return this->_param_value;};
95                   int get_param_value_size(){return this->_param_value_size;};
96
97
98   };
99   std::vector<RANParamIEs> * get_list() const {return _param_list.get();};
100   int get_list_count() const {return _count_list;};
101   bool encode(unsigned char *, size_t *);
102   std::string  get_error (void) const {return _error_string ;};
103   void add(RANParamIEs ie_obj){
104           _param_list.get()->push_back(ie_obj);
105           _count_list ++;
106   }
107
108 private:
109   std::unique_ptr<std::vector<RANParamIEs>> _param_list;
110   int _count_list;
111   E2SM_HelloWorld_ActionDefinition_t* _action_defn;
112   E2SM_HelloWorld_ActionDefinition_Format1_t _action_fmt1;
113   RANparameter_Item_t* _ranparam_ie;
114
115   size_t _errbuf_len = 128;
116   char _errbuf[128];
117   std::string _error_string;
118
119   bool setfields(E2SM_HelloWorld_ActionDefinition_t *);
120
121
122 };
123
124
125 #endif /* XAPP_ASN_REFACTOR_E2SM_SUBSCRIPTION_HPP_ */