Init basesystem source codes.
[staging/basesystem.git] / video_in_hal / nsframework / notification_persistent_service / server / src / notificationpersistentservice_main.cpp
1 /*
2  * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 ////////////////////////////////////////////////////////////////////////////////////////////////////
18 /// \defgroup <<Group Tag>> <<Group Name>>
19 /// \ingroup  tag_NS_NPPService
20 /// .
21 ////////////////////////////////////////////////////////////////////////////////////////////////////
22
23 ////////////////////////////////////////////////////////////////////////////////////////////////////
24 /// \ingroup  tag_NS_NPPService
25 /// \brief
26 ///
27 ///
28 ///
29 ////////////////////////////////////////////////////////////////////////////////////////////////////
30
31 ////////////////////////////////////////////////////////////////////////////////////////////////////
32 // Include Files
33 ////////////////////////////////////////////////////////////////////////////////////////////////////
34 #include <native_service/ns_version.h>
35 #include <native_service/ns_version_if.h>
36 #include <native_service/frameworkunified_dispatcher.h>
37 #include <native_service/frameworkunified_framework_if.h>
38
39 #include <stdlib.h>
40 #include <cstdlib>
41 #include <iostream>
42
43 #include "ns_npp.h"  // for static members. Set thread prio.
44 #include "ns_npp_notificationpersistentservicelog.h"
45 #include "ns_npp_persistence_manager.h"  // for static members. Set enable/disable persistence feature.
46
47 const CHAR AppName[] = FRAMEWORKUNIFIED_NS_NPSERVICE;  // NOLINT (readability/naming)
48 CHAR g_csendreadyackto[MAX_QUEUE_NAME_SIZE];
49
50 CFrameworkunifiedVersion g_FrameworkunifiedVersion(MAJORNO, MINORNO, REVISION);  // NOLINT (readability/naming)
51
52 // Argument Parser for NSNPP
53 EFrameworkunifiedStatus NPPArgumentParser(SI_32 f_iargument, PCHAR f_pargumentvalue);
54
55 FRAMEWORKUNIFIEDLOGPARAM g_FrameworkunifiedLogParams = { // NOLINT (readability/naming)
56   FRAMEWORKUNIFIEDLOGOPTIONS,
57   {
58     ZONE_TEXT_10, ZONE_TEXT_11, ZONE_TEXT_12,
59     ZONE_TEXT_13, ZONE_TEXT_14, ZONE_TEXT_15,
60     ZONE_TEXT_16, ZONE_TEXT_17, ZONE_TEXT_18,
61     ZONE_TEXT_19, ZONE_TEXT_20, ZONE_TEXT_21,
62     ZONE_TEXT_22, ZONE_TEXT_23, ZONE_TEXT_24,
63     ZONE_TEXT_25, ZONE_TEXT_26, ZONE_TEXT_27,
64     ZONE_TEXT_28, ZONE_TEXT_29, ZONE_TEXT_30,
65     ZONE_TEXT_31,
66   },
67   FRAMEWORKUNIFIEDLOGZONES
68 };
69
70 extern const FrameworkunifiedDefaultCallbackHandler kDefaultCbHandler;
71
72
73 ////////////////////////////////////////////////////////////////////////////////////////////////////
74 //  Function : main
75 ////////////////////////////////////////////////////////////////////////////////////////////////////
76
77 int main(int argc, char *argv[]) {
78   FRAMEWORKUNIFIED_SET_ZONES();
79   CustomCommandLineOptions l_tcmdlineoptions = { "i:e:w:fa:v:", NULL, NPPArgumentParser};
80   EFrameworkunifiedStatus l_estatus = FrameworkunifiedDispatcherWithArguments(AppName, argc, argv, &kDefaultCbHandler, &l_tcmdlineoptions);
81
82   return static_cast<SI_32>(l_estatus);
83 }
84
85 EFrameworkunifiedStatus NPPArgumentParser(SI_32 f_iargument, PCHAR f_pargumentvalue) {
86   EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
87   SI_32 l_iTmpArgValue = 0;
88   switch (f_iargument) {  // LCOV_EXCL_BR_LINE 8: cannot test
89     // Disable Persistence
90     case 'f': {
91         CPersistenceManager::m_bPersistenceDisabled =  TRUE;
92         break;
93       }
94     case 'i': {
95         l_iTmpArgValue = atoi(f_pargumentvalue);
96         if (l_iTmpArgValue > 0) {  // LCOV_EXCL_BR_LINE 8: cannot test
97           CNSNPP::m_siImmediatePersistenceThreadPrio = l_iTmpArgValue;
98         }
99         break;
100       }
101     case 'e': {
102         l_iTmpArgValue = atoi(f_pargumentvalue);
103         if (l_iTmpArgValue > 0) {  // LCOV_EXCL_BR_LINE 8: cannot test
104           CNSNPP::m_siReadThreadPrio = l_iTmpArgValue;
105         }
106         break;
107       }
108     case 'w': {
109         l_iTmpArgValue = atoi(f_pargumentvalue);
110         if (l_iTmpArgValue > 0) {  // LCOV_EXCL_BR_LINE 8: cannot test
111           CNSNPP::m_siWriteThreadPrio = l_iTmpArgValue;
112         }
113         break;
114       }
115     case 'a': {
116         std::memset(g_csendreadyackto, 0, MAX_QUEUE_NAME_SIZE);
117         std::strncpy(g_csendreadyackto, f_pargumentvalue, (MAX_QUEUE_NAME_SIZE - 1));
118         break;
119       }
120     case 'v': {
121         l_iTmpArgValue = atoi(f_pargumentvalue);
122         CNSNPP::m_siCRCCheckCount = static_cast<UI_16>(l_iTmpArgValue);
123         break;
124       }
125
126     default:
127       l_estatus = eFrameworkunifiedStatusFail;
128       break;
129   }
130   return l_estatus;
131 }