1st Version
This commit is contained in:
41
CMakeLists.txt
Normal file
41
CMakeLists.txt
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
|
||||||
|
cmake_minimum_required(VERSION 3.5)
|
||||||
|
set(CMAKE_TRY_COMPILE_TARGET_TYPE "STATIC_LIBRARY")
|
||||||
|
|
||||||
|
# Find python and Boost - both are required dependencies
|
||||||
|
find_package(PythonLibs 3.10 REQUIRED)
|
||||||
|
find_package(Boost COMPONENTS python REQUIRED)
|
||||||
|
|
||||||
|
# Without this, any build libraries automatically have names "lib{x}.so"
|
||||||
|
set(CMAKE_SHARED_MODULE_PREFIX "")
|
||||||
|
|
||||||
|
add_definitions(-DBOOST_BIND_GLOBAL_PLACEHOLDERS)
|
||||||
|
|
||||||
|
|
||||||
|
#set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
|
||||||
|
set (CMAKE_RUNTIME_OUTPUT_DIRECTORY /home/markus/git/vrpmdvweb/vrpmdvserver/extensions/rt_service)
|
||||||
|
|
||||||
|
# Add a shared module - modules are intended to be imported at runtime.
|
||||||
|
# - This is where you add the source files
|
||||||
|
add_library(rt_service MODULE rt_service.cpp)
|
||||||
|
|
||||||
|
# Set up the libraries and header search paths for this target
|
||||||
|
target_link_libraries(rt_service ${Boost_LIBRARIES} ${PYTHON_LIBRARIES})
|
||||||
|
target_include_directories(rt_service PRIVATE ${PYTHON_INCLUDE_DIRS})
|
||||||
|
|
||||||
|
set(MY_RESOURCE_FILE rt_service.so)
|
||||||
|
#set_directory_properties(MY_EXTENSION_LIB /home/markus/git/vrpmwvweb/vrpmdvserver/extensions/)
|
||||||
|
#file(COPY ${CMAKE_CURRENT_BINARY_DIR}/${MY_RESOURCE_FILE}
|
||||||
|
# DESTINATION /home/markus/git/vrpmdvweb/vrpmdvserver/extensions/rt_service)
|
||||||
|
|
||||||
|
|
||||||
|
# location of the Python header files
|
||||||
|
#PYTHON_VERSION = 3.10
|
||||||
|
#PYTHON_INCLUDE = /usr/include/python$(PYTHON_VERSION)
|
||||||
|
# location of the Boost Python include files and library
|
||||||
|
#BOOST_INC = /usr/include
|
||||||
|
#BOOST_LIB = /usr/lib
|
||||||
|
# compile mesh classes
|
||||||
|
#TARGET = rt_service
|
||||||
|
#$(TARGET).so: $(TARGET).o g++ -shared -Wl,--export-dynamic $(TARGET).o -L$(BOOST_LIB) -lboost_python-$(PYTHON_VERSION) -L/usr/lib/python$(PYTHON_VERSION)/config -lpython$(PYTHON_VERSION) -o $(TARGET).so
|
||||||
|
#$(TARGET).o: $(TARGET).cpp g++ -I$(PYTHON_INCLUDE) -I$(BOOST_INC) -fPIC -c $(TARGET).cpp
|
||||||
69
rt_service.cpp
Normal file
69
rt_service.cpp
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
#include <boost/python.hpp>
|
||||||
|
#include <boost/python/list.hpp>
|
||||||
|
#include <boost/python/extract.hpp>
|
||||||
|
#include <string>
|
||||||
|
//#include <sstream>
|
||||||
|
//#include <vector>
|
||||||
|
|
||||||
|
struct RTService
|
||||||
|
{
|
||||||
|
// private:
|
||||||
|
// /* data */
|
||||||
|
|
||||||
|
// public:
|
||||||
|
// RT_Service(/* args */) {}
|
||||||
|
|
||||||
|
// ~RT_Service() {}
|
||||||
|
|
||||||
|
bool createMonitoring(std::string id) {
|
||||||
|
//TODO ML: add this to the M4Core
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool deleteMonitoring(std::string id) {
|
||||||
|
//TODO ML: add this to the M4Core
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string getMonitoringState(std::string id) {
|
||||||
|
//TODO ask the M4Core for the Monitpring Status
|
||||||
|
return "Start";
|
||||||
|
}
|
||||||
|
|
||||||
|
boost::python::list getMonitoringStates() {
|
||||||
|
//TODO ask the M4Core for the Monitpring Status
|
||||||
|
boost::python::list list;
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool setMonitoringStatus(std::string id, std::string status) {
|
||||||
|
//set the Status
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
using namespace boost::python;
|
||||||
|
|
||||||
|
BOOST_PYTHON_MODULE(rt_service)
|
||||||
|
{
|
||||||
|
class_<RTService>("RT_Service")
|
||||||
|
.def("createMonitoring", &RTService::createMonitoring)
|
||||||
|
.def("getMonitoringStatus", &RTService::getMonitoringState)
|
||||||
|
.def("getAllMonitoringStat", &RTService::getMonitoringStates)
|
||||||
|
.def("setMonitoringStatus", &RTService::setMonitoringStatus)
|
||||||
|
;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//examples
|
||||||
|
// long l = len(msgs);
|
||||||
|
// std::stringstream ss;
|
||||||
|
// for (long i = 0; i<l; ++i) {
|
||||||
|
// if (i>0) ss << ", ";
|
||||||
|
// std::string s = boost::python::extract<std::string>(msgs[i]);
|
||||||
|
// ss << s;
|
||||||
|
// }
|
||||||
|
// mMsg = ss.str();
|
||||||
Reference in New Issue
Block a user