AI Watch A1
Multi-person 3D skeleton detection using Intel RealSense and OpenPose with Kafka support.
UsageManager.cpp
Go to the documentation of this file.
1//
2// UsageManager.cpp
3// AI Watch A1
4//
5// Created by Denny Caruso on 23/07/22.
6//
7
8// License: Apache 2.0. See LICENSE file in root directory.
9// Copyright(c) 2022. All Rights Reserved.
10
11#include "UsageManager.hpp"
12
13
14
17
18
19
21 if (* get_argc() != get_expected_argc()) {
22 std::string buffer = "Usage: ./" + std::string((* get_argv())[programNameOffset]) + std::string(get_expectedUsageMessage()) + " -- " + std::string(CHECK_USAGE_SCOPE);
23 CV_Error(CHECK_USAGE_ERROR, buffer);
24 }
25}
26
28 return this->expected_argc;
29}
30
32 return this->expectedUsageMessage;
33}
34
35
36
38 for (unsigned int i = 0; i < * get_argc(); i++) delete [] (* get_argv())[i];
39 delete get_argc();
40 delete get_argv();
41 delete sharedInstance;
42}
43
44UsageManager * UsageManager::getInstance (int * argc, char *** argv, const int expected_argc, const char * expectedUsageMessage) {
45 std::lock_guard <std::mutex> lock(singletonMutex);
47 return sharedInstance;
48}
49
51 std::lock_guard <std::mutex> lock(singletonMutex);
52 if (sharedInstance == nullptr) return nullptr;
53 return sharedInstance;
54}
55
57 return this->argc;
58}
59
60char *** UsageManager::get_argv (void) {
61 std::stringstream openPoseTerminalCommand;
62 UsageManager * usageManagerInstance = UsageManager::getInstance();
63 if (usageManagerInstance == nullptr) CV_Error(USAGE_MANAGER_NULLPTR_ERROR, USAGE_MANAGER_NULLPTR_SCOPE);
64 return usageManagerInstance->argv;
65}
UsageManager class is a utility class that helps with configuration parameters.
void checkUsage(void)
Checks if the configuration parameters are valid and if they are equal to the number of the expected ...
static std::mutex singletonMutex
Mutex for thread-safe access.
int * get_argc(void)
Get the argc's pointer.
const char * get_expectedUsageMessage(void)
Get the expected usage message.
virtual ~UsageManager()
Destroy the Usage Manager object.
const char * expectedUsageMessage
a simple message that lets the user understand how to properly run the executable.
char *** get_argv(void)
Get the argv's pointer.
int * argc
configuration parameters' number.
char *** argv
configuration parameters.
UsageManager(int *argc=nullptr, char ***argv=nullptr, const int expected_argc=0, const char *expectedUsageMessage=nullptr)
Construct a new UsageManager object.
static UsageManager * sharedInstance
The field for storing the singleton instance.
const int get_expected_argc(void)
Get the expected argc value.
static UsageManager * getInstance(void)
Get the unique class instance. This methods should be called in the following scenario: when we just ...
const int expected_argc
expected configuration parameters' number.
static const char * CHECK_USAGE_SCOPE
Definition: constants.hpp:18
static const short int USAGE_MANAGER_NULLPTR_ERROR
Definition: constants.hpp:35
static const short int programNameOffset
Definition: constants.hpp:61
static const char * USAGE_MANAGER_NULLPTR_SCOPE
Definition: constants.hpp:36
static const short int CHECK_USAGE_ERROR
Definition: constants.hpp:17
const char * expectedUsageMessage
Definition: main.cpp:214
const int expected_argc
Definition: main.cpp:213