Init folder for HW Xapp
[ric-app/hw.git] / src / hw_xapp_main.cc
1 /*
2 ==================================================================================
3         Copyright (c) 2018-2019 AT&T Intellectual Property.
4
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
8
9        http://www.apache.org/licenses/LICENSE-2.0
10
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 ==================================================================================
17 */
18 /*
19  * hw_xapp_main.cc
20  * Created on: Dec, 2019
21  * Author: Shraboni Jana
22  */
23
24 #include "xapp.hpp"
25 #include "subscription_request.hpp"
26 #include "xapp_sdl.hpp"
27
28 void signalHandler( int signum ) {
29    cout << "Interrupt signal (" << signum << ") received.\n";
30    exit(signum);
31 }
32
33 int main(int argc, char *argv[]){
34
35         //get configuration
36         XappSettings config;
37         //change the priority depending upon application requirement
38         config.loadDefaultSettings();
39         config.loadEnvVarSettings();
40         config.loadCmdlineSettings(argc, argv);
41
42         //getting the listening port and xapp name info
43         std::string  port = config[XappSettings::SettingName::HW_PORTS];
44         std::string  name = config[XappSettings::SettingName::XAPP_NAME];
45
46
47         //initialize rmr
48         std::unique_ptr<XappRmr> rmr;
49         rmr = std::make_unique<XappRmr>(name,port);
50         rmr->xapp_rmr_init();
51
52         //Register signal handler to stop
53         signal(SIGINT, signalHandler);
54         signal(SIGTERM, signalHandler);
55
56         //Test SDL.
57         XappSDL sdl = XappSDL("hw-xapp");
58
59         //Initiate the Xapp functionality
60         std::unique_ptr<Xapp> hw_xapp = std::make_unique<Xapp>(std::ref(config), std::ref(*rmr),std::ref(sdl));
61
62
63         //define the startup mode.
64         hw_xapp->startup();
65
66         //Register Callback Handlers
67         //Register E2 Msg Handlers - Subscription/Indication.
68         //Register A1 Msg Handlers.
69         //Register Callback Handlers
70
71
72         //start the receiver thread listening at HW_PORT
73         //currently only one receiver thread. In total how many receiver threads depend on the xapp developer.
74         //Register all the handlers required and start the receiver
75
76         //register_msgproc(RIC_SUB_RESP, sub_handler);
77         //register_msgproc(RIC_SUB_DEL_RESP, sub_handler);
78         //register_msgproc(RIC_SUB_FAILURE, sub_handler);
79
80
81         hw_xapp->start_xapp_receiver();
82         sleep(5);
83
84
85         //Delete all subscriptions if any based on Xapp Mode.
86         //xapp->shutdown();
87
88          while(1){
89                                 sleep(1);
90                          }
91
92         return 0;
93 }
94
95
96