--- /dev/null
+/*\r
+==================================================================================\r
+ Copyright (c) 2018-2019 AT&T Intellectual Property.\r
+\r
+ Licensed under the Apache License, Version 2.0 (the "License");\r
+ you may not use this file except in compliance with the License.\r
+ You may obtain a copy of the License at\r
+\r
+ http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+ Unless required by applicable law or agreed to in writing, software\r
+ distributed under the License is distributed on an "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ See the License for the specific language governing permissions and\r
+ limitations under the License.\r
+==================================================================================\r
+*/\r
+\r
+#pragma once\r
+\r
+#ifndef S_RESPONSE_HELPER_\r
+#define S_RESPONSE_HELPER_\r
+\r
+#include <vector>\r
+#include <memory>\r
+\r
+/* Simple structure to store action for RICaction of the Subscription response based on E2 v0.22 */\r
+struct ActionResponse {\r
+public:\r
+ ActionResponse(int id): _is_admit(true), _id(id), _cause(-1), _sub_cause(-1){};\r
+ ActionResponse(int id, int cause, int sub_cause): _is_admit(false), _id(id), _cause(cause), _sub_cause(sub_cause){};\r
+ \r
+ int get_id() const{\r
+ return _id;\r
+ };\r
+\r
+ int get_cause() const{\r
+ return _cause;\r
+ };\r
+\r
+ int get_sub_cause() const{\r
+ return _sub_cause;\r
+ };\r
+\r
+ bool is_admitted(void){\r
+ return _is_admit;\r
+ };\r
+ \r
+private:\r
+\r
+ bool _is_admit;\r
+ int _id, _cause, _sub_cause;\r
+ \r
+};\r
+\r
+\r
+struct subscription_response_helper {\r
+ \r
+public:\r
+\r
+ using action_t = std::vector<ActionResponse>;\r
+ \r
+ subscription_response_helper(void){\r
+ _action_admitted_ref = std::make_unique<action_t>();\r
+ _action_not_admitted_ref = std::make_unique<action_t>();\r
+ \r
+ };\r
+ \r
+ // copy operator\r
+ subscription_response_helper(const subscription_response_helper &he ){\r
+ _action_admitted_ref = std::make_unique<action_t>();\r
+ _action_not_admitted_ref = std::make_unique<action_t>();\r
+ \r
+ _req_id = he.get_request_id();\r
+ _req_seq_no = he.get_req_seq();\r
+ _func_id = he.get_function_id();\r
+ \r
+ // Take care of the actions\r
+ for (auto const & e: *(he.get_admitted_list())){\r
+ add_action(e.get_id());\r
+ }\r
+ \r
+ for(auto const & e: *(he.get_not_admitted_list())){\r
+ add_action(e.get_id(), e.get_cause(), e.get_sub_cause());\r
+ };\r
+ }\r
+ \r
+\r
+ // assignment operator\r
+ void operator=(const subscription_response_helper & he){\r
+ _action_admitted_ref = std::make_unique<action_t>();\r
+ _action_not_admitted_ref = std::make_unique<action_t>();\r
+ \r
+ _req_id = he.get_request_id();\r
+ _req_seq_no = he.get_req_seq();\r
+ _func_id = he.get_function_id();\r
+ \r
+ \r
+ // Take care of the actions\r
+ for (auto const & e: *(he.get_admitted_list())){\r
+ add_action(e.get_id());\r
+ }\r
+ \r
+ for(auto const & e: *(he.get_not_admitted_list())){\r
+ add_action(e.get_id(), e.get_cause(), e.get_sub_cause());\r
+ };\r
+ \r
+ }\r
+ \r
+ action_t * get_admitted_list (void ) const {return _action_admitted_ref.get();};\r
+ action_t * get_not_admitted_list (void ) const{return _action_not_admitted_ref.get();};\r
+ \r
+ void set_request(int id, int seq_no){\r
+ _req_id = id;\r
+ _req_seq_no = seq_no;\r
+ \r
+ };\r
+\r
+ void clear(void){\r
+ _action_admitted_ref.get()->clear();\r
+ _action_not_admitted_ref.get()->clear();\r
+ }\r
+\r
+ \r
+ void set_function_id(int id){\r
+ _func_id = id;\r
+ };\r
+\r
+ void add_action(int id){\r
+ ActionResponse a(id) ;\r
+ _action_admitted_ref.get()->push_back(a);\r
+ };\r
+\r
+ void add_action(int id, int cause, int sub_cause){\r
+ ActionResponse a (id, cause, sub_cause);\r
+ _action_not_admitted_ref.get()->push_back(a);\r
+ };\r
+\r
+\r
+ int get_request_id(void) const{\r
+ return _req_id;\r
+ }\r
+ \r
+ int get_req_seq(void) const{\r
+ return _req_seq_no;\r
+ }\r
+\r
+ int get_function_id(void) const{\r
+ return _func_id;\r
+ }\r
+ \r
+ std::string to_string(void){\r
+ std::string Info;\r
+ Info += "Request ID = " + std::to_string(_req_id) + "\n";\r
+ Info += "Request Sequence No = " + std::to_string(_req_seq_no) + "\n";\r
+ Info += "RAN Function ID = " + std::to_string(_func_id) + "\n";\r
+ Info += "Actions Admitted =\n";\r
+ int i = 0;\r
+ for(auto & e: *(_action_admitted_ref)){\r
+ Info += std::to_string(i) + ": ID=" + std::to_string(e.get_id()) + "\n";\r
+ i++;\r
+ } \r
+ Info += "Actions Not Admitted =\n";\r
+ i = 0;\r
+ for(auto & e: *(_action_not_admitted_ref)){\r
+ 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
+ i++;\r
+ } \r
+ \r
+ return Info;\r
+ } \r
+\r
+private:\r
+ int _req_id, _req_seq_no, _func_id;\r
+ std::unique_ptr<action_t> _action_admitted_ref;\r
+ std::unique_ptr<action_t> _action_not_admitted_ref;\r
+ \r
+};\r
+ \r
+\r
+#endif\r