From 5cb799a703be14925b5e99162461e68ba7a81a56 Mon Sep 17 00:00:00 2001 From: Fabian Posch Date: Mon, 8 Jan 2024 14:12:34 -0500 Subject: [PATCH] add shared library for main functionality --- CMakeLists.txt | 1 + include/actsim_agent/actsim_agent.hpp | 32 +++++++++++++++++++++++++++ src/CMakeLists.txt | 7 ++---- src/actsim_agent/CMakeLists.txt | 13 +++++++++++ src/actsim_agent/actsim_agent.cpp | 31 ++++++++++++++++++++++++++ src/main.cpp | 5 ++++- 6 files changed, 83 insertions(+), 6 deletions(-) create mode 100644 include/actsim_agent/actsim_agent.hpp create mode 100644 src/actsim_agent/CMakeLists.txt create mode 100644 src/actsim_agent/actsim_agent.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index f7aa09b..05cd677 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -77,6 +77,7 @@ target_link_libraries( ${PROJECT_NAME} # act-deploy-commands act-deploy-db-lib + actsim-agent-lib # act-deploy-pipeline-modules-lib # act-deploy-test-gen-modules-lib # yaml-cpp diff --git a/include/actsim_agent/actsim_agent.hpp b/include/actsim_agent/actsim_agent.hpp new file mode 100644 index 0000000..8201090 --- /dev/null +++ b/include/actsim_agent/actsim_agent.hpp @@ -0,0 +1,32 @@ +/************************************************************************* + * + * This file is part of the ACT library + * + * Copyright (c) 2024 Fabian Posch + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + ************************************************************************** + */ + +#ifndef __ACTSIM_AGENT__ +#define __ACTSIM_AGENT__ + +#include "db_types.hpp" + +int start_agent(db::db_credentials_t db_cred, size_t worker_processes); + +#endif diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 5a3b04e..2ff8d25 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -2,14 +2,11 @@ # Grab necessary libraries from ACT_HOME #include_directories($ENV{ACT_HOME}/include) include_directories(../include) -#include_directories(../include/commands) include_directories(../include/db_lib) +include_directories(../include/actsim_agent) add_subdirectory(db_lib) -#add_subdirectory(pipeline_lib) -#add_subdirectory(pipeline_modules) -#add_subdirectory(testcase_generators) -#add_subdirectory(commands) +add_subdirectory(actsim_agent) file( GLOB proj_SRC diff --git a/src/actsim_agent/CMakeLists.txt b/src/actsim_agent/CMakeLists.txt new file mode 100644 index 0000000..20fe9ea --- /dev/null +++ b/src/actsim_agent/CMakeLists.txt @@ -0,0 +1,13 @@ +include_directories(../../include/db_lib) +include_directories(../../include/actsim_agent) + +file( + GLOB actsim_agent_SRC + "*.cpp" +) + +add_library( + actsim-agent-lib + SHARED + ${actsim_agent_SRC} +) \ No newline at end of file diff --git a/src/actsim_agent/actsim_agent.cpp b/src/actsim_agent/actsim_agent.cpp new file mode 100644 index 0000000..4618cc9 --- /dev/null +++ b/src/actsim_agent/actsim_agent.cpp @@ -0,0 +1,31 @@ +/************************************************************************* + * + * This file is part of the ACT library + * + * Copyright (c) 2024 Fabian Posch + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + ************************************************************************** + */ + +#include +#include "actsim_agent.hpp" + +int start_agent(db::db_credentials_t db_cred, size_t worker_processes) { + std::cout << "Hello world from the agent." << std::endl; + return 0; +} \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index ed92897..cb07653 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -25,6 +25,7 @@ #include #include #include +#include #include "cli_util.hpp" #include "db_types.hpp" #include "util.h" @@ -157,6 +158,8 @@ int main (int argc, char **argv) { exit(1); } - std::cout << "Hello world!" << std::endl; + DEBUG_PRINT("Starting actsim agent with " + std::to_string(jobs) + " worker threads."); + + return start_agent(db_cred, jobs); }