pmt: Write the function base

- Write the function manager.
 - Make minor changes to the function structure.
 - Add CLI11 license.
 - Added main function to libpmt.
This commit is contained in:
2025-07-28 22:36:15 +03:00
parent 40260d5ae3
commit a58adb6a28
13 changed files with 280 additions and 80 deletions

25
include/CLI/LICENSE Normal file
View File

@@ -0,0 +1,25 @@
CLI11 2.5 Copyright (c) 2017-2025 University of Cincinnati, developed by Henry
Schreiner under NSF AWARD 1414736. All rights reserved.
Redistribution and use in source and binary forms of CLI11, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors
may be used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View File

@@ -14,6 +14,13 @@
limitations under the License.
*/
/**
* WARNING
* --------
* This library (libpmt) isn't exactly suitable for use in different projects.
* But I'm not saying I've tested it or anything like that.
*/
#ifndef LIBPMT_LIB_HPP
#define LIBPMT_LIB_HPP
@@ -25,9 +32,12 @@
#include <libhelper/lib.hpp>
#include <libpartition_map/lib.hpp>
#define PMT "libpmt"
#define PMTE "pmt"
#define PMTF "libpmt-function-manager"
#ifdef NEED_BASIC_FUNCTION_CLASSES
#include <memory>
#pragma GCC diagnostic push
#pragma GCC diagnostic ignore "-Wdeprecated-declarations"
#include <CLI/CLI11.hpp>
@@ -36,12 +46,11 @@
namespace PartitionManager {
#ifdef NEED_BASIC_FUNCTION_CLASSES
class basic_function {
/**
* Example variables for writing your function:
* private:
* CLI::App _cmd* = nullptr;
* public:
* CLI::App cmd* = nullptr;
*/
public:
virtual bool init(CLI::App& _app) = 0;
@@ -56,25 +65,35 @@ private:
public:
void registerFunction(std::unique_ptr<basic_function> _func, CLI::App& _app);
const char* whatIsRunnedCommandName();
void startUsedFunctions();
bool handleAll();
};
class basic_variables {
public:
basic_variables();
PartitionMap::BuildMap PartMap;
std::string searchPath;
bool onLogical;
bool silentProcess;
bool verboseMode;
bool viewVersion;
};
using FunctionBase = basic_function;
using FunctionManager = basic_function_manager;
using VariableTable = basic_variables;
using Error = Helper::Error;
#endif // #ifdef NEED_BASIC_FUNCTION_CLASSES
namespace Variables {
extern PartitionMap::BuildMap PartMap;
} // namespace Variables
VariableTable* Variables;
int Main(int argc, char** argv);
std::string getLibVersion();
std::string getAppVersion();
std::string getAppVersion(); // Not Android app version (an Android app is planned!), tells pmt and libs versions.
} // namespace PartitionManager