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