2 ==================================================================================
3 Copyright (c) 2019-2020 AT&T Intellectual Property.
5 Licensed under the Apache License, Version 2.0 (the "License");
6 you may not use this file except in compliance with the License.
7 You may obtain a copy of the License at
9 http://www.apache.org/licenses/LICENSE-2.0
11 Unless required by applicable law or agreed to in writing, software
12 distributed under the License is distributed on an "AS IS" BASIS,
13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 See the License for the specific language governing permissions and
15 limitations under the License.
16 ==================================================================================
21 #ifndef S_RESPONSE_HELPER_
22 #define S_RESPONSE_HELPER_
27 /* Simple structure to store action for RICaction of the Subscription response based on E2 v0.31 */
28 struct ActionResponse {
30 ActionResponse(int id): _is_admit(true), _id(id), _cause(-1), _sub_cause(-1){};
31 ActionResponse(int id, int cause, int sub_cause): _is_admit(false), _id(id), _cause(cause), _sub_cause(sub_cause){};
37 int get_cause() const{
41 int get_sub_cause() const{
45 bool is_admitted(void){
52 int _id, _cause, _sub_cause;
57 struct subscription_response_helper {
61 using action_t = std::vector<ActionResponse>;
63 subscription_response_helper(void){
64 _action_admitted_ref = std::make_unique<action_t>();
65 _action_not_admitted_ref = std::make_unique<action_t>();
70 subscription_response_helper(const subscription_response_helper &he ){
71 _action_admitted_ref = std::make_unique<action_t>();
72 _action_not_admitted_ref = std::make_unique<action_t>();
74 _req_id = he.get_request_id();
75 _req_seq_no = he.get_req_seq();
76 _func_id = he.get_function_id();
78 // Take care of the actions
79 for (auto const & e: *(he.get_admitted_list())){
80 add_action(e.get_id());
83 for(auto const & e: *(he.get_not_admitted_list())){
84 add_action(e.get_id(), e.get_cause(), e.get_sub_cause());
89 // assignment operator
90 void operator=(const subscription_response_helper & he){
91 _action_admitted_ref = std::make_unique<action_t>();
92 _action_not_admitted_ref = std::make_unique<action_t>();
94 _req_id = he.get_request_id();
95 _req_seq_no = he.get_req_seq();
96 _func_id = he.get_function_id();
99 // Take care of the actions
100 for (auto const & e: *(he.get_admitted_list())){
101 add_action(e.get_id());
104 for(auto const & e: *(he.get_not_admitted_list())){
105 add_action(e.get_id(), e.get_cause(), e.get_sub_cause());
110 action_t * get_admitted_list (void ) const {return _action_admitted_ref.get();};
111 action_t * get_not_admitted_list (void ) const{return _action_not_admitted_ref.get();};
113 void set_request(int id, int seq_no){
115 _req_seq_no = seq_no;
120 _action_admitted_ref.get()->clear();
121 _action_not_admitted_ref.get()->clear();
125 void set_function_id(int id){
129 void add_action(int id){
130 ActionResponse a(id) ;
131 _action_admitted_ref.get()->push_back(a);
134 void add_action(int id, int cause, int sub_cause){
135 ActionResponse a (id, cause, sub_cause);
136 _action_not_admitted_ref.get()->push_back(a);
140 int get_request_id(void) const{
144 int get_req_seq(void) const{
148 int get_function_id(void) const{
152 std::string to_string(void){
154 Info += "Request ID = " + std::to_string(_req_id) + "\n";
155 Info += "Request Sequence No = " + std::to_string(_req_seq_no) + "\n";
156 Info += "RAN Function ID = " + std::to_string(_func_id) + "\n";
157 Info += "Actions Admitted =\n";
159 for(auto & e: *(_action_admitted_ref)){
160 Info += std::to_string(i) + ": ID=" + std::to_string(e.get_id()) + "\n";
163 Info += "Actions Not Admitted =\n";
165 for(auto & e: *(_action_not_admitted_ref)){
166 Info += std::to_string(i) + ": ID=" + std::to_string(e.get_id()) + ": Cause =" + std::to_string(e.get_cause()) + ": Sub-Cause=" + std::to_string(e.get_sub_cause()) + "\n";
174 int _req_id, _req_seq_no, _func_id;
175 std::unique_ptr<action_t> _action_admitted_ref;
176 std::unique_ptr<action_t> _action_not_admitted_ref;