From 1870270ae01bf39a4a725589386faa1dcad1c292 Mon Sep 17 00:00:00 2001 From: brichards Date: Tue, 16 Jan 2024 18:24:04 +0000 Subject: [PATCH 01/18] datamodel base class added --- DataModel/DataModel.cpp | 2 +- DataModel/DataModel.h | 14 +--- DataModel/Utilities.cpp | 71 ---------------- DataModel/Utilities.h | 82 ------------------- UserTools/DummyTool/DummyTool.h | 1 + UserTools/template/MyTool.h | 2 +- UserTools/template/MyToolDynamicMultiThread.h | 1 + UserTools/template/MyToolMultiThread.h | 1 + UserTools/template/MyToolThread.h | 1 + src/Tool/Tool.h | 9 +- src/ToolChain/ToolChain.cpp | 10 +-- src/ToolChain/ToolChain.h | 8 +- src/main.cpp | 4 +- 13 files changed, 28 insertions(+), 178 deletions(-) delete mode 100644 DataModel/Utilities.cpp delete mode 100644 DataModel/Utilities.h diff --git a/DataModel/DataModel.cpp b/DataModel/DataModel.cpp index 0726544..adf44b8 100644 --- a/DataModel/DataModel.cpp +++ b/DataModel/DataModel.cpp @@ -1,6 +1,6 @@ #include "DataModel.h" -DataModel::DataModel(){ Log=0;} +DataModel::DataModel():DataModelBase(){} /* TTree* DataModel::GetTTree(std::string name){ diff --git a/DataModel/DataModel.h b/DataModel/DataModel.h index 5fe9682..69c9f76 100644 --- a/DataModel/DataModel.h +++ b/DataModel/DataModel.h @@ -11,6 +11,7 @@ #include "Store.h" #include "BStore.h" #include "Logging.h" +#include "DataModelBase.h" /** * \class DataModel @@ -23,7 +24,8 @@ * */ -class DataModel { + +class DataModel: public DataModelBase { public: @@ -33,16 +35,8 @@ class DataModel { //TTree* GetTTree(std::string name); //void AddTTree(std::string name,TTree *tree); //void DeleteTTree(std::string name,TTree *tree); - - Logging *Log; ///< Log class pointer for use in Tools, it can be used to send messages which can have multiple error levels and destination end points - - Store vars; ///< This Store can be used for any variables. It is an inefficent ascii based storage and command line arguments will be placed in here along with ToolChain variables - BStore CStore; ///< This is a more efficent binary Store that can be used to store a dynamic set of inter Tool variables, very useful for constants and and flags hence the name CStore - std::map Stores; ///< This is a map of named BStore pointers which can be deffined to hold a nammed collection of any type of BStore. It is usefull to store data collections that needs subdividing into differnt stores. - - - private: + // private: //std::map m_trees; diff --git a/DataModel/Utilities.cpp b/DataModel/Utilities.cpp deleted file mode 100644 index 1eb43b6..0000000 --- a/DataModel/Utilities.cpp +++ /dev/null @@ -1,71 +0,0 @@ -#include - -Utilities::Utilities(){ - Threads.clear(); -} - - -Thread_args* Utilities::CreateThread(std::string ThreadName, void (*func)(Thread_args*), Thread_args* args){ - - if(Threads.count(ThreadName)==0){ - - if(args==0) args = new Thread_args(); - - args->ThreadName=ThreadName; - args->func=func; - args->running=true; - - pthread_create(&(args->thread), NULL, Utilities::Thread, args); - - Threads[ThreadName]=args; - -} - - else args=0; - - return args; - -} - - -void *Utilities::Thread(void *arg){ - - Thread_args *args = static_cast(arg); - - while (!args->kill){ - - if(args->running) args->func(args ); - else usleep(100); - - } - - pthread_exit(NULL); - -} - - -bool Utilities::KillThread(Thread_args* &args){ - - bool ret=false; - - if(args){ - - args->running=false; - args->kill=true; - - pthread_join(args->thread, NULL); - //delete args; - //args=0; - - } - - return ret; - -} - -bool Utilities::KillThread(std::string ThreadName){ - - return KillThread(Threads[ThreadName]); - -} - diff --git a/DataModel/Utilities.h b/DataModel/Utilities.h deleted file mode 100644 index d3244ab..0000000 --- a/DataModel/Utilities.h +++ /dev/null @@ -1,82 +0,0 @@ -#ifndef UTILITIES_H -#define UTILITIES_H - -#include -#include -#include -#include -#include -#include - -/** - * \struct DataModelThread_args - * - * This is both an base class for any thread argument struct used in the tool threaded Tool templates. -Effectivly this acts as a place to put variable that are specfic to that thread and can be used as a place to transfer variables from the main thread to sub threads. - * - * - * $Author: B.Richards $ - * $Date: 2019/05/26 18:34:00 $ - * - */ - -struct Thread_args{ - - Thread_args(){ ///< Simple constructor - kill=false; - running=false; - } - - virtual ~Thread_args(){ ///< virtual constructor - running =false; - kill=true; - } - - std::string ThreadName; ///< name of thread (deffined at creation) - void (*func)(Thread_args*); ///< function pointer to thread with args - pthread_t thread; ///< Simple constructor underlying thread that interface is built ontop of - bool running; ///< Bool flag to tell the thread to run (if not set thread goes into wait cycle - bool kill; ///< Bool flay used to kill the thread - -}; - - -/** - * \class Utilities - * - * This class can be instansiated in a Tool and provides some helpful threading, dynamic socket descovery and promotion functionality - * - * - * $Author: B.Richards $ - * $Date: 2019/05/26 18:34:00 $ - * - */ - -class Utilities{ - - public: - - Utilities(); ///< Simple constructor - Thread_args* CreateThread(std::string ThreadName, void (*func)(Thread_args*), Thread_args* args); ///< Create a thread with more complicated data exchange definned by arguments - bool KillThread(Thread_args* &args); ///< Kill a thread assosiated to args - bool KillThread(std::string ThreadName); ///< Kill a thread by name - - template bool KillThread(T* pointer){ - - Thread_args* tmp=pointer; - return KillThread(tmp); - - } ///< Kill a thread with args that inheirt form base Thread_args - - - - protected: - - static void* Thread(void *arg); ///< Thread with args - std::map Threads; ///< Map of threads managed by the utilities class. - - -}; - - -#endif diff --git a/UserTools/DummyTool/DummyTool.h b/UserTools/DummyTool/DummyTool.h index e7bc429..38cfb02 100644 --- a/UserTools/DummyTool/DummyTool.h +++ b/UserTools/DummyTool/DummyTool.h @@ -5,6 +5,7 @@ #include #include "Tool.h" +#include "DataModel.h" /** * \class DummyTool diff --git a/UserTools/template/MyTool.h b/UserTools/template/MyTool.h index 0439927..a2638be 100644 --- a/UserTools/template/MyTool.h +++ b/UserTools/template/MyTool.h @@ -5,7 +5,7 @@ #include #include "Tool.h" - +#include "DataModel.h" /** * \class MyTool diff --git a/UserTools/template/MyToolDynamicMultiThread.h b/UserTools/template/MyToolDynamicMultiThread.h index ece7ac9..a0606ad 100644 --- a/UserTools/template/MyToolDynamicMultiThread.h +++ b/UserTools/template/MyToolDynamicMultiThread.h @@ -5,6 +5,7 @@ #include #include "Tool.h" +#include "DataModel.h" /** * \struct MyToolDynamicMultiThread_args diff --git a/UserTools/template/MyToolMultiThread.h b/UserTools/template/MyToolMultiThread.h index 62c48e0..0c5e16d 100644 --- a/UserTools/template/MyToolMultiThread.h +++ b/UserTools/template/MyToolMultiThread.h @@ -5,6 +5,7 @@ #include #include "Tool.h" +#include "DataModel.h" /** * \struct MyToolMultiThread_args diff --git a/UserTools/template/MyToolThread.h b/UserTools/template/MyToolThread.h index d2a4c91..af9439e 100644 --- a/UserTools/template/MyToolThread.h +++ b/UserTools/template/MyToolThread.h @@ -5,6 +5,7 @@ #include #include "Tool.h" +#include "DataModel.h" /** * \struct MyToolThread_args_args diff --git a/src/Tool/Tool.h b/src/Tool/Tool.h index 124e659..9869311 100644 --- a/src/Tool/Tool.h +++ b/src/Tool/Tool.h @@ -4,9 +4,10 @@ #include #include "Store.h" -#include "DataModel.h" #include +#include "Logging.h" +class DataModel; /** * \class Tool @@ -37,9 +38,9 @@ class Tool{ Logging* m_log; ///< Pointer to logging class int m_verbose; ///< verbosity variable for direct logging level MsgL ML(int messagelevel) {return MsgL(messagelevel,m_verbose);} ///< Function for setting logging level instream @param messagelevel the verboisty level at which to show the message. Checked against internal verbosity level. - void MLC() {*(m_data->Log)< void Log(T message, int messagelevel, int verbosity){m_data->Log->Log(message,messagelevel,verbosity);} - template void Log(T message, int messagelevel=0){m_data->Log->Log(message,messagelevel,m_verbose);} ///< Logging fuction for printouts. @param message Templated message string. @param messagelevel The verbosity level at which to show the message. Checked against internal verbosity level + void MLC() {*(m_log)< void Log(T message, int messagelevel, int verbosity){m_log->Log(message,messagelevel,verbosity);} + template void Log(T message, int messagelevel=0){m_log->Log(message,messagelevel,m_verbose);} ///< Logging fuction for printouts. @param message Templated message string. @param messagelevel The verbosity level at which to show the message. Checked against internal verbosity level private: diff --git a/src/ToolChain/ToolChain.cpp b/src/ToolChain/ToolChain.cpp index 44ea0fb..82a17b9 100644 --- a/src/ToolChain/ToolChain.cpp +++ b/src/ToolChain/ToolChain.cpp @@ -1,8 +1,8 @@ #include "ToolChain.h" -ToolChain::ToolChain(std::string configfile, int argc, char* argv[]){ +ToolChain::ToolChain(std::string configfile, DataModel* data_model, int argc, char* argv[]){ - m_data=new DataModel(); + m_data=reinterpret_cast(data_model); if(!m_data->vars.Initialise(configfile)){ std::clog<<"\033[38;5;196m ERROR!!!: No valid config file quitting \033[0m"<(in_data_model); Init(); @@ -128,7 +128,7 @@ int ToolChain::Initialise(){ try{ #endif - if(m_tools.at(i)->Initialise(m_configfiles.at(i), *m_data)) *m_log<Initialise(m_configfiles.at(i), *(reinterpret_cast(m_data)))) *m_log< #include "Tool.h" -#include "DataModel.h" +#include "DataModelBase.h" #include "Logging.h" #include "Factory.h" #include "Store.h" +class DataModel; + /** * \struct ToolChainargs * @@ -49,7 +51,7 @@ class ToolChain{ public: ToolChain(){}; - ToolChain(std::string configfile, int argc=0, char* argv[]=0); ///< Constructor that obtains all of the configuration varaibles from an input file. @param configfile The path and name of the config file to read configuration values from. + ToolChain(std::string configfile, DataModel* data_model, int argc=0, char* argv[]=0); ///< Constructor that obtains all of the configuration varaibles from an input file. @param configfile The path and name of the config file to read configuration values from. /** Constructor with explicit configuration variables passed as arguments. @@ -72,7 +74,7 @@ logmode Where log printouts should be forwarded too. "Interactive" = cout, "Remo int Finalise(); ///< Finalise all Tools in the ToolCahin sequentially. void Interactive(); ///< Start interactive thread to accept commands and run ToolChain in interactive mode. bool LoadTools(std::string filename); - DataModel* m_data; ///< Direct access to transient data model class of the Tools in the ToolChain. This allows direct initialisation and copying of variables. + DataModelBase* m_data; ///< Direct access to transient data model class of the Tools in the ToolChain. This allows direct initialisation and copying of variables. protected: diff --git a/src/main.cpp b/src/main.cpp index 0ab8938..6ae6d15 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,5 +1,6 @@ #include #include "ToolChain.h" +#include "DataModel.h" //#include "DummyTool.h" int main(int argc, char* argv[]){ @@ -8,7 +9,8 @@ int main(int argc, char* argv[]){ if (argc==1)config_file="configfiles/Dummy/ToolChainConfig"; else config_file=argv[1]; - ToolChain tools(config_file, argc, argv); +DataModel* data_model = new DataModel(); + ToolChain tools(config_file, data_model, argc, argv); //DummyTool dummytool; From 2df50eb284cca53be42c8d78a40bc4e692a11175 Mon Sep 17 00:00:00 2001 From: brichards Date: Tue, 16 Jan 2024 21:48:01 +0000 Subject: [PATCH 02/18] added namespace and updated makefile --- DataModel/DataModel.h | 3 +- Makefile | 128 ++++--- UnitTests/StoreTest.cpp | 2 + UserTools/Factory/Factory.h | 2 + src/Logging/Logging.cpp | 1 + src/Logging/Logging.h | 331 +++++++++--------- src/Store/BStore.cpp | 2 + src/Store/BStore.h | 415 +++++++++++------------ src/Store/BinaryStream.cpp | 2 + src/Store/BinaryStream.h | 596 +++++++++++++++++---------------- src/Store/PointerWrapper.h | 67 ++-- src/Store/SerialisableObject.h | 85 ++--- src/Store/Store.cpp | 1 + src/Store/Store.h | 220 ++++++------ src/Tool/Tool.h | 86 ++--- src/ToolChain/ToolChain.cpp | 2 + src/ToolChain/ToolChain.h | 183 +++++----- src/main.cpp | 12 +- 18 files changed, 1088 insertions(+), 1050 deletions(-) diff --git a/DataModel/DataModel.h b/DataModel/DataModel.h index 69c9f76..5059d43 100644 --- a/DataModel/DataModel.h +++ b/DataModel/DataModel.h @@ -13,6 +13,8 @@ #include "Logging.h" #include "DataModelBase.h" +using namespace ToolFramework; + /** * \class DataModel * @@ -24,7 +26,6 @@ * */ - class DataModel: public DataModelBase { diff --git a/Makefile b/Makefile index 368b3b8..a11b3e7 100644 --- a/Makefile +++ b/Makefile @@ -1,98 +1,94 @@ -CXXFLAGS= -fPIC -O3 -Wpedantic -Wall +SOURCEDIR=/host/Dependencies/ToolFrameworkCore + +CXXFLAGS= -fPIC -O3 -Wpedantic -Wall -std=c++11 -Wno-comment -Wno-unused -Wextra -Wcast-align -Wcast-qual -Wctor-dtor-privacy -Wdisabled-optimization -Wformat=2 -Winit-self -Wlogical-op -Wmissing-declarations -Wmissing-include-dirs -Wnoexcept -Woverloaded-virtual -Wredundant-decls -Wshadow -Wsign-conversion -Wsign-promo -Wstrict-null-sentinel -Wstrict-overflow=5 -Wswitch-default -Wundef #-Werror -Wold-style-cast + ifeq ($(MAKECMDGOALS),debug) CXXFLAGS+= -O0 -g -lSegFault -rdynamic -DDEBUG endif +TempDataModelInclude = +TempDataModelLib = -DataModelInclude = -DataModelLib = - -MyToolsInclude = -MyToolsLib = - - -debug: all - -all: lib/libMyTools.so lib/libToolChain.so lib/libStore.so include/Tool.h lib/libDataModel.so lib/libLogging.so main - -main: src/main.cpp lib/libStore.so lib/libLogging.so lib/libToolChain.so | lib/libMyTools.so lib/libDataModel.so - @echo -e "\e[38;5;214m\n*************** Making " $@ "****************\e[0m" - g++ $(CXXFLAGS) src/main.cpp -o main -I include -L lib -lStore -lMyTools -lToolChain -lDataModel -lLogging -lpthread $(DataModelInclude) $(MyToolsInclude) $(MyToolsLib) $(DataModelLib) - - -lib/libStore.so: src/Store/* - - @echo -e "\e[38;5;214m\n*************** Making " $@ "****************\e[0m" - cp src/Store/*.h include/ - g++ $(CXXFLAGS) -shared -I include src/Store/*.cpp -o lib/libStore.so - +TempToolsInclude = +TempToolsLib = -include/Tool.h: src/Tool/Tool.h - - @echo -e "\e[38;5;214m\n*************** Making " $@ "****************\e[0m" - cp src/Tool/Tool.h include/ +Includes=-I $(SOURCEDIR)/include/ +Libs=-L $(SOURCEDIR)/lib/ -lStore -lLogging -lToolchain -lTempDataModelBase -lTempDataModel -lTempTools -lpthread +LIBRARIES=lib/libStore.so lib/libLogging.so lib/libToolChain.so lib/libTempDataModelbase.so lib/libTempDataModel.so lib/libTempTools.so +HEADERS:=$(patsubst %.h, include/%.h, $(filter %.h, $(subst /, ,$(patsubst src/%.h, include/%.h, $(wildcard src/*/*.h) )))) +TempDataModelHEADERS:=$(patsubst %.h, include/%.h, $(filter %.h, $(subst /, ,$(patsubst src/%.h, include/%.h, $(wildcard DataModel/*.h))))) +MyToolHEADERS:=$(patsubst %.h, include/%.h, $(filter %.h, $(subst /, ,$(patsubst src/%.h, include/%.h, $(wildcard UserTools/*/*.h) $(wildcard UserTools/*.h))))) +SOURCEFILES:=$(patsubst %.cpp, %.o, $(wildcard */*.cpp) $(wildcard */*/*.cpp)) -lib/libToolChain.so: src/ToolChain/* lib/libStore.so include/Tool.h lib/libLogging.so | lib/libDataModel.so lib/libMyTools.so +#.SECONDARY: $(%.o) - @echo -e "\e[38;5;214m\n*************** Making " $@ "****************\e[0m" - cp src/ToolChain/ToolChain.h include/ - g++ $(CXXFLAGS) -shared src/ToolChain/ToolChain.cpp -I include -lpthread -L lib -lStore -lDataModel -lMyTools -lLogging -o lib/libToolChain.so $(DataModelInclude) $(MyToolsInclude) $(MyToolsLib) $(DataModelLib) +all: $(HEADERS) $(TempDataModelHEADERS) $(MyToolHEADERS) $(SOURCEFILES) $(LIBRARIES) main -clean: +debug: all - @echo -e "\e[38;5;201m\n*************** Cleaning up ****************\e[0m" - rm -f include/*.h - rm -f lib/*.so - rm -f main - rm -f UserTools/*/*.o - rm -f DataModel/*.o +main: src/main.o $(LIBRARIES) $(HEADERS) $(TempDataModelHEADERS) $(MyToolHEADERS) | $(SOURCEFILES) + @echo -e "\e[38;5;11m\n*************** Making " $@ " ****************\e[0m" + g++ $(CXXFLAGS) $< -o $@ $(Includes) $(Libs) $(TempDataModelInclude) $(TempDataModellib) $(TempToolsInclude) $(TempToolslib) -lib/libDataModel.so: DataModel/* lib/libLogging.so lib/libStore.so $(patsubst DataModel/%.cpp, DataModel/%.o, $(wildcard DataModel/*.cpp)) +include/%.h: + @echo -e "\e[38;5;87m\n*************** sym linking headers ****************\e[0m" + ln -s `pwd`/$(filter %$(strip $(patsubst include/%.h, /%.h, $@)), $(wildcard src/*/*.h) $(wildcard DataModel/*.h) $(wildcard UserTools/*/*.h) $(wildcard UserTools/*.h)) $@ +src/%.o : src/%.cpp $(HEADERS) @echo -e "\e[38;5;214m\n*************** Making " $@ "****************\e[0m" - g++ $(CXXFLAGS) -shared DataModel/*.o -I include -L lib -lStore -lLogging -o lib/libDataModel.so $(DataModelInclude) $(DataModelLib) - - -lib/libMyTools.so: UserTools/*/* UserTools/* lib/libStore.so include/Tool.h lib/libLogging.so UserTools/Factory/Factory.o | lib/libDataModel.so + g++ $(CXXFLAGS) -c $< -o $@ $(Includes) +UnitTests/%.o : UnitTests/%.cpp $(HEADERS) @echo -e "\e[38;5;214m\n*************** Making " $@ "****************\e[0m" - g++ $(CXXFLAGS) -shared UserTools/*/*.o -I include -L lib -lStore -lDataModel -lLogging -o lib/libMyTools.so $(MyToolsInclude) $(DataModelInclude) $(MyToolsLib) $(DataModelLib) - + g++ $(CXXFLAGS) -c $< -o $@ $(Includes) -lib/libLogging.so: src/Logging/* lib/libStore.so +UserTools/%.o : UserTools/%.cpp $(HEADERS) $(TempDataModelHEADERS) UserTools/%.h @echo -e "\e[38;5;214m\n*************** Making " $@ "****************\e[0m" - cp src/Logging/Logging.h include/ - g++ $(CXXFLAGS) -shared -I include src/Logging/Logging.cpp -o lib/libLogging.so -L lib/ -lStore + g++ $(CXXFLAGS) -c $< -o $@ $(Includes) $(TempDataModelInclude) $(TempToolsInclude) - -UserTools/Factory/Factory.o: UserTools/Factory/Factory.cpp lib/libStore.so include/Tool.h lib/libLogging.so lib/libDataModel.so $(patsubst UserTools/%.cpp, UserTools/%.o, $(wildcard UserTools/*/*.cpp)) | include/Tool.h +DataModel/%.o : DataModel/%.cpp DataModel/%.h $(HEADERS) $(TempDataModelHEADERS) @echo -e "\e[38;5;214m\n*************** Making " $@ "****************\e[0m" - cp UserTools/Factory/Factory.h include - cp UserTools/Unity.h include - -g++ $(CXXFLAGS) -c -o $@ $< -I include -L lib -lStore -lDataModel -lLogging $(MyToolsInclude) $(MyToolsLib) $(DataModelInclude) $(DataModelLib) + g++ $(CXXFLAGS) -c $< -o $@ $(Includes) $(TempDataModelInclude) +lib/libStore.so: $(patsubst %.cpp, %.o , $(wildcard src/Store/*.cpp)) | $(HEADERS) + @echo -e "\e[38;5;201m\n*************** Making " $@ "****************\e[0m" + g++ $(CXXFLAGS) --shared $^ -o $@ $(Includes) -UserTools/%.o: UserTools/%.cpp lib/libStore.so include/Tool.h lib/libLogging.so lib/libDataModel.so | include/Tool.h - @echo -e "\e[38;5;214m\n*************** Making " $@ "****************\e[0m" - cp $(shell dirname $<)/*.h include - -g++ $(CXXFLAGS) -c -o $@ $< -I include -L lib -lStore -lDataModel -lLogging $(MyToolsInclude) $(MyToolsLib) $(DataModelInclude) $(DataModelLib) +lib/libLogging.so: $(patsubst %.cpp, %.o , $(wildcard src/Logging/*.cpp)) | $(HEADERS) + @echo -e "\e[38;5;201m\n*************** Making " $@ "****************\e[0m" + g++ $(CXXFLAGS) --shared $^ -o $@ $(Includes) +lib/libTempDataModelbase.so: $(patsubst %.cpp, %.o , $(wildcard src/DataModelBase/*.cpp)) | $(HEADERS) + @echo -e "\e[38;5;201m\n*************** Making " $@ "****************\e[0m" + g++ $(CXXFLAGS) --shared $^ -o $@ $(Includes) -target: remove $(patsubst %.cpp, %.o, $(wildcard UserTools/$(TOOL)/*.cpp)) +lib/libToolChain.so: $(patsubst %.cpp, %.o , $(wildcard src/ToolChain/*.cpp)) | $(HEADERS) + @echo -e "\e[38;5;201m\n*************** Making " $@ "****************\e[0m" + g++ $(CXXFLAGS) --shared $^ -o $@ $(Includes) -remove: - @echo -e "removing" - -rm UserTools/$(TOOL)/*.o - -rm include/$(TOOL).h +lib/libTempDataModel.so: $(patsubst %.cpp, %.o , $(wildcard DataModel/*.cpp)) | $(HEADERS) $(TempDataModelInclude) + @echo -e "\e[38;5;201m\n*************** Making " $@ "****************\e[0m" + g++ $(CXXFLAGS) --shared $^ -o $@ $(Includes) $(TempDataModelInclude) +lib/libTempTools.so: $(patsubst %.cpp, %.o , $(wildcard UserTools/*/*.cpp)) | $(HEADERS) $(TempDataModelInclude) $(TempToolsInclude) + @echo -e "\e[38;5;201m\n*************** Making " $@ "****************\e[0m" + g++ $(CXXFLAGS) --shared $^ -o $@ $(Includes) $(TempDataModelInclude) $(TempToolsInclude) -DataModel/%.o: DataModel/%.cpp lib/libLogging.so lib/libStore.so - @echo -e "\e[38;5;214m\n*************** Making " $@ "****************\e[0m" - cp $(shell dirname $<)/*.h include - -g++ $(CXXFLAGS) -c -o $@ $< -I include -L lib -lStore -lLogging $(DataModelInclude) $(DataModelLib) +clean: + @echo -e "\e[38;5;201m\n*************** Cleaning up ****************\e[0m" + rm -f */*/*.o + rm -f */*.o + rm -f include/*.h + rm -f lib/*.so Docs: doxygen Doxyfile + + +test: $(patsubst %.cpp, %.o, $(wildcard */*.cpp) $(wildcard */*/*.cpp)) + echo + echo $(patsubst %.cpp, %.o, $(wildcard */*.cpp) $(wildcard */*/*.cpp)) +# echo $(patsubst %, lib/Lib%.so, $(filter-out %.o %.cpp src, $(subst /, , $(wildcard src/*)))) diff --git a/UnitTests/StoreTest.cpp b/UnitTests/StoreTest.cpp index 371487b..e1f1721 100644 --- a/UnitTests/StoreTest.cpp +++ b/UnitTests/StoreTest.cpp @@ -1,6 +1,8 @@ #include #include +using namespace ToolFramework; + int test_counter=0; template int Test(T &a, T &b, std::string message=""){ diff --git a/UserTools/Factory/Factory.h b/UserTools/Factory/Factory.h index e322791..32ce6da 100644 --- a/UserTools/Factory/Factory.h +++ b/UserTools/Factory/Factory.h @@ -4,6 +4,8 @@ #include #include "Tool.h" +using namespace ToolFramework; + /** * Global Factory function for creating Tools. @param tool Name of the Tool class to create. diff --git a/src/Logging/Logging.cpp b/src/Logging/Logging.cpp index 6c7ff63..7f7e74f 100644 --- a/src/Logging/Logging.cpp +++ b/src/Logging/Logging.cpp @@ -1,5 +1,6 @@ #include "Logging.h" +using namespace ToolFramework; Logging::TFStreamBuf::~TFStreamBuf(){ diff --git a/src/Logging/Logging.h b/src/Logging/Logging.h index d12d93c..fe45a5f 100644 --- a/src/Logging/Logging.h +++ b/src/Logging/Logging.h @@ -11,6 +11,8 @@ #include #include +namespace ToolFramework{ + #define red "\033[38;5;196m" #define darkred "\033[38;5;88m" #define green "\033[38;5;46m" @@ -31,83 +33,83 @@ #define gray "\033[38;5;243m" #define plain "\033[0m" -/** - * \struct MsgL - * - *This struct variables for setting the message level of streamed messages to the logging class - * - * - * $Author: B.Richards $ - * $Date: 2020/12/30 12:50:00 $ - */ - -struct MsgL{ - - MsgL(int in_messagelevel, int in_verbose){ - messagelevel=in_messagelevel; - verbose=in_verbose; - } - MsgL ML(int in_messagelevel) { - messagelevel=in_messagelevel; - return *this; - } + /** + * \struct MsgL + * + *This struct variables for setting the message level of streamed messages to the logging class + * + * + * $Author: B.Richards $ + * $Date: 2020/12/30 12:50:00 $ + */ - int messagelevel; ///< Message level paramiter - int verbose; ///< Verbosity level pramiter + struct MsgL{ + + MsgL(int in_messagelevel, int in_verbose){ + messagelevel=in_messagelevel; + verbose=in_verbose; + } + MsgL ML(int in_messagelevel) { + messagelevel=in_messagelevel; + return *this; + } + + int messagelevel; ///< Message level paramiter + int verbose; ///< Verbosity level pramiter + + }; + + + /** + * \class Logging + * + *This class handels the logging, which can be directed to screen or file or over the via the ToolChain Config file + * + * + * $Author: B.Richards $ + * $Date: 2019/05/27 18:34:00 $ + */ -}; - - -/** - * \class Logging - * - *This class handels the logging, which can be directed to screen or file or over the via the ToolChain Config file - * - * - * $Author: B.Richards $ - * $Date: 2019/05/27 18:34:00 $ - */ - - - -class Logging: virtual public std::ostream { - - public: - class TFStreamBuf: virtual public std::stringbuf - { - - public: - - TFStreamBuf(){}; - TFStreamBuf(bool interactive, bool local=false, std::string localpath="./log", bool error=false, std::ostream* filestream=0); - - virtual ~TFStreamBuf(); - - virtual int sync ( ); - - bool ChangeOutFile(std::string localpath); - - int m_messagelevel; - int m_verbose; - - std::ostream* output; - std::ostream* fileoutput; - - protected: - - std::ostream* tmp; - - bool m_local; - bool m_interactive; - bool m_error; - - std::ofstream file; - std::streambuf *psbuf, *backup1, *backup2; - - bool no_delete; - }; - + + class Logging: virtual public std::ostream { + + public: + + class TFStreamBuf: virtual public std::stringbuf + { + + public: + + TFStreamBuf(){}; + TFStreamBuf(bool interactive, bool local=false, std::string localpath="./log", bool error=false, std::ostream* filestream=0); + + virtual ~TFStreamBuf(); + + virtual int sync ( ); + + bool ChangeOutFile(std::string localpath); + + int m_messagelevel; + int m_verbose; + + std::ostream* output; + std::ostream* fileoutput; + + protected: + + std::ostream* tmp; + + bool m_local; + bool m_interactive; + bool m_error; + + std::ofstream file; + std::streambuf *psbuf, *backup1, *backup2; + + bool no_delete; + }; + /** Constructor for Logging class @@ -117,49 +119,49 @@ class Logging: virtual public std::ostream { @param localpath Local path for log output file @param split_output_files if log is directed to disk then whether or nto to use sperate files for standard output and standard error */ - + // Logging(std::ostream& str, std::string mode, std::string localpath=""):std::ostream(&buffer), buffer(str, mode, localpath){}; - + //Logging(std::ostream& str, std::string mode, std::string localpath=""):std::ostream(buffer), buffer(new MyStreamBuf(str, mode, localpath)), errbuffer(new MyStreamBuf(str, mode, localpath)){}; - - Logging(bool interactive, bool local=false, std::string localpath="./log", bool split_output_files=false);//:buffer(new MyStreamBuf(interactive, local, localpath, false)),errbuffer(new MyStreamBuf(interactive, local, localpath, true)){}; - - //:std::ostream(buffer){}; - //, buffer(new MyStreamBuf(interactive, local, "", error)){}; - - Logging(){}; - - virtual ~Logging(); - - /** - Function to create a log messages. - - @param message templated log message text. - @param messagelevel message verbosity level of the message being sent (e.g. if 'messagelevel>= verbose' Then message is sent). - @param verbose verbosity level of the current Tool. - - */ - - template void Log(T message, int messagelevel=1, int verbose=1){ - - - if(messagelevel<=verbose){ - int previous_messagelevel = buffer->m_messagelevel; - int previous_verbosity = buffer->m_verbose; - - buffer->m_messagelevel=messagelevel; - buffer->m_verbose=verbose; - - std::cout.rdbuf(buffer); - std::cout<m_messagelevel=previous_messagelevel; - buffer->m_verbose=previous_verbosity; - } - - } - - + + Logging(bool interactive, bool local=false, std::string localpath="./log", bool split_output_files=false);//:buffer(new MyStreamBuf(interactive, local, localpath, false)),errbuffer(new MyStreamBuf(interactive, local, localpath, true)){}; + + //:std::ostream(buffer){}; + //, buffer(new MyStreamBuf(interactive, local, "", error)){}; + + Logging(){}; + + virtual ~Logging(); + + /** + Function to create a log messages. + + @param message templated log message text. + @param messagelevel message verbosity level of the message being sent (e.g. if 'messagelevel>= verbose' Then message is sent). + @param verbose verbosity level of the current Tool. + + */ + + template void Log(T message, int messagelevel=1, int verbose=1){ + + + if(messagelevel<=verbose){ + int previous_messagelevel = buffer->m_messagelevel; + int previous_verbosity = buffer->m_verbose; + + buffer->m_messagelevel=messagelevel; + buffer->m_verbose=verbose; + + std::cout.rdbuf(buffer); + std::cout<m_messagelevel=previous_messagelevel; + buffer->m_verbose=previous_verbosity; + } + + } + + /** Functionn to change the logs out file if set to a local path. @@ -167,54 +169,55 @@ class Logging: virtual public std::ostream { @return value is bool success of opening new logfile. */ - bool ChangeOutFile(std::string localpath){return buffer->ChangeOutFile(localpath);} - - - - - Logging& operator<<(MsgL a){ - - buffer->m_messagelevel=a.messagelevel; - buffer->m_verbose=a.verbose; - - return *this; - } - - - Logging& operator<<(std::ostream& (*foo)(std::ostream&)) { - - std::cout.rdbuf(buffer); - std::cout< Logging& operator<<(T &a){ - - std::cout.rdbuf(buffer); - std::cout< Logging& operator<<(const T &a){ - - std::cout.rdbuf(buffer); - std::cout<ChangeOutFile(localpath);} + + + + + Logging& operator<<(MsgL a){ + + buffer->m_messagelevel=a.messagelevel; + buffer->m_verbose=a.verbose; + + return *this; + } + + + Logging& operator<<(std::ostream& (*foo)(std::ostream&)) { + + std::cout.rdbuf(buffer); + std::cout< Logging& operator<<(T &a){ + + std::cout.rdbuf(buffer); + std::cout< Logging& operator<<(const T &a){ + + std::cout.rdbuf(buffer); + std::cout< +using namespace ToolFramework; + //////////////////////// //Notes for Ben /////////////////////////////// diff --git a/src/Store/BStore.h b/src/Store/BStore.h index a8f5a7f..0b973d0 100644 --- a/src/Store/BStore.h +++ b/src/Store/BStore.h @@ -16,239 +16,242 @@ #include #include -enum enum_type {uncompressed, compressed, post_pre_compress, ram}; - - -/** - * \class BStore - * - * This class Is a dynamic data storeage class and can be used to store variables of any type listed by ASCII key. The storage of the varaible is a binarystream. - * - * $Author: B.Richards $ - * $Date: 2022/01/23 10:44:00 $ - */ - - - -class BStore: public SerialisableObject{ - -#define CHUNK 16384 +namespace ToolFramework{ - public: - - BStore(bool header=true, bool type_checking=false); - BStore(const BStore &bs); - ~BStore(); - // void Init(); - // void Init2(); - bool Initnew(std::string filename, enum_type type=post_pre_compress, bool header=true, bool type_checking=false, unsigned int file_end=0); - bool Initnew(BinaryStream& bs, unsigned int position); - bool GetFlags(unsigned int file_end); - bool GetFlags(std::string filename, unsigned int file_end); - bool WriteHeader(); - bool WriteLookup(); - bool WriteFlags(); - bool Save(unsigned int entry=0); - bool GetHeader(); - bool GetEntry(unsigned int entry_request); - bool DeleteEntry(unsigned int entry_request); - unsigned int NumEntries(); - bool Close(); - bool Rollback(); - - std::string GetVersion(); + enum enum_type {uncompressed, compressed, post_pre_compress, ram}; - - std::map m_variables; - std::map m_type_info; - // std::map m_header; - BStore* Header; - std::map m_ptrs; - - - /////////importing - void JsonParser(std::string input); ///< Converts a flat JSON formatted string to Store entries in the form of key value pairs. @param input The input flat JSON string. - bool Print(); - void Print(bool values); ///< Prints the contents of the BoostStore. @param values If true values and keys are printed. If false just keys are printed - void Delete(); ///< Deletes all entries in the BoostStore. - void Remove(std::string key); ///< Removes a single entry from the BoostStore. @param key The key of the entry to remove. - std::string Type(std::string key); ///< Queries the type of an entry if type checking is turned on. @param key The key of the entry to check. @return A string encoding the type info. - bool Has(std::string key); ///< Queries if entry exists in a BoostStore. @param key is the key of the varaible to look up. @return true if varaible is present in the store, false if not. - // BoostStore *Header; ///< Pointer to header BoostStore (only available in multi event BoostStore). This can be used to access and assign header varaibles jsut like a standard non multi event store. - /** - Templated getter function for BoostStore content. Assignment is templated and via reference. - @param name The ASCII key that the variable in the BoostStore is stored with. - @param out The variable to fill with the value. - @return Return value is true if varaible exists in the Store and false if not or wrong type. - */ - template bool Get(std::string name,T &out){ - - if(m_variables.count(name)>0){ - - if(m_type_info[name]==typeid(out).name() || !m_type_checking){ - - m_variables[name].m_pos=0; - return m_variables[name] >> out; - + * \class BStore + * + * This class Is a dynamic data storeage class and can be used to store variables of any type listed by ASCII key. The storage of the varaible is a binarystream. + * + * $Author: B.Richards $ + * $Date: 2022/01/23 10:44:00 $ + */ + + + + class BStore: public SerialisableObject{ + +#define CHUNK 16384 + + public: + + BStore(bool header=true, bool type_checking=false); + BStore(const BStore &bs); + ~BStore(); + // void Init(); + // void Init2(); + bool Initnew(std::string filename, enum_type type=post_pre_compress, bool header=true, bool type_checking=false, unsigned int file_end=0); + bool Initnew(BinaryStream& bs, unsigned int position); + bool GetFlags(unsigned int file_end); + bool GetFlags(std::string filename, unsigned int file_end); + bool WriteHeader(); + bool WriteLookup(); + bool WriteFlags(); + bool Save(unsigned int entry=0); + bool GetHeader(); + bool GetEntry(unsigned int entry_request); + bool DeleteEntry(unsigned int entry_request); + unsigned int NumEntries(); + bool Close(); + bool Rollback(); + + std::string GetVersion(); + + + std::map m_variables; + std::map m_type_info; + // std::map m_header; + BStore* Header; + std::map m_ptrs; + + + /////////importing + + void JsonParser(std::string input); ///< Converts a flat JSON formatted string to Store entries in the form of key value pairs. @param input The input flat JSON string. + bool Print(); + void Print(bool values); ///< Prints the contents of the BoostStore. @param values If true values and keys are printed. If false just keys are printed + void Delete(); ///< Deletes all entries in the BoostStore. + void Remove(std::string key); ///< Removes a single entry from the BoostStore. @param key The key of the entry to remove. + std::string Type(std::string key); ///< Queries the type of an entry if type checking is turned on. @param key The key of the entry to check. @return A string encoding the type info. + bool Has(std::string key); ///< Queries if entry exists in a BoostStore. @param key is the key of the varaible to look up. @return true if varaible is present in the store, false if not. + // BoostStore *Header; ///< Pointer to header BoostStore (only available in multi event BoostStore). This can be used to access and assign header varaibles jsut like a standard non multi event store. + + /** + Templated getter function for BoostStore content. Assignment is templated and via reference. + @param name The ASCII key that the variable in the BoostStore is stored with. + @param out The variable to fill with the value. + @return Return value is true if varaible exists in the Store and false if not or wrong type. + */ + template bool Get(std::string name,T &out){ + + if(m_variables.count(name)>0){ + + if(m_type_info[name]==typeid(out).name() || !m_type_checking){ + + m_variables[name].m_pos=0; + return m_variables[name] >> out; + + } + else return false; } + else return false; + } - else return false; - - } - - /** - Templated getter function for pointer to BoostStore content. Assignment is templated and the object is created on first the heap and a pointer to it assigned. Latter requests will return a pointer to the first object. Bote the pointer is to an indipendant instance of the stored object and so changing its value without using a Setter will not effect the stored value. - @param name The ASCII key that the variable in the BoostStore is stored with. - @param out The pointer to assign. - @return Return value is true if varaible exists in the Store and false if not or wrong type. - */ - template bool Get(std::string name,T* &out){ - - if(m_variables.count(name)>0 || m_ptrs.count(name)>0){ - if((m_type_info[name]==typeid(T).name() || !m_type_checking ) || (m_ptrs.count(name)>0 && m_variables.count(name)==0)){ - - bool ret=true; - if(m_ptrs.count(name)==0){ + /** + Templated getter function for pointer to BoostStore content. Assignment is templated and the object is created on first the heap and a pointer to it assigned. Latter requests will return a pointer to the first object. Bote the pointer is to an indipendant instance of the stored object and so changing its value without using a Setter will not effect the stored value. + @param name The ASCII key that the variable in the BoostStore is stored with. + @param out The pointer to assign. + @return Return value is true if varaible exists in the Store and false if not or wrong type. + */ + template bool Get(std::string name,T* &out){ + + if(m_variables.count(name)>0 || m_ptrs.count(name)>0){ + if((m_type_info[name]==typeid(T).name() || !m_type_checking ) || (m_ptrs.count(name)>0 && m_variables.count(name)==0)){ + + bool ret=true; + if(m_ptrs.count(name)==0){ + + T* tmp=new T; + m_ptrs[name]=new PointerWrapper(tmp); + ret*=Get(name,*tmp); + } + + + PointerWrapper* tmp=static_cast* >(m_ptrs[name]); + out=tmp->pointer; + + return ret; - T* tmp=new T; - m_ptrs[name]=new PointerWrapper(tmp); - ret*=Get(name,*tmp); } - - - PointerWrapper* tmp=static_cast* >(m_ptrs[name]); - out=tmp->pointer; - - return ret; + else return false; } + else return false; - + } - - else return false; - - } - - - /** - Templated setter function to assign vairables in the BoostStore. - @param name The key to be used to store and reference the variable in the BoostStore. - @param in the varaible to be stored. - */ - template bool Set(std::string name,T& in){ - //std::cout<<"in set"<::iterator it=m_variables.begin(); it!=m_variables.end(); ++it){ - if (!first) stream<<","; - stream<<"\""<first<<"\":\""<< it->second.buffer<<"\""; - first=false; + + /** + Allows streaming of a flat JASON formatted string of BoostStore contents. + */ + template void operator>>(T& obj){ + + std::stringstream stream; + stream<<"{"; + bool first=true; + for (std::map::iterator it=m_variables.begin(); it!=m_variables.end(); ++it){ + if (!first) stream<<","; + stream<<"\""<first<<"\":\""<< it->second.buffer<<"\""; + first=false; + } + stream<<"}"; + + obj=stream.str(); + } - stream<<"}"; - obj=stream.str(); + bool Serialise(BinaryStream &bs); + + // std::map m_lookup; //why is this a map?? should change it when you ahve had more sleep + + std::vector m_lookup; + + BinaryStream output; - } - - bool Serialise(BinaryStream &bs); - - // std::map m_lookup; //why is this a map?? should change it when you ahve had more sleep - - std::vector m_lookup; - - BinaryStream output; - private: - - - - unsigned int m_file_end; - std::string m_file_name; - unsigned int m_open_file_end; - unsigned int m_previous_file_end; - enum_type m_type; - bool m_type_checking; - bool m_has_header; - unsigned int m_header_start; - - unsigned int m_flags_start; - - - unsigned int m_lookup_start; - //unsigned int m_lookup_size; - - // std::map m_lookup; - //unsigned int m_entry; - // unsigned int m_current_loaded_entry; - bool m_update; - - //int m_file_type; //0=gzopen, 1=fopen, 2=stringstream - float m_version; - - -}; + + + + unsigned int m_file_end; + std::string m_file_name; + unsigned int m_open_file_end; + unsigned int m_previous_file_end; + enum_type m_type; + bool m_type_checking; + bool m_has_header; + unsigned int m_header_start; + + unsigned int m_flags_start; + + + unsigned int m_lookup_start; + //unsigned int m_lookup_size; + + // std::map m_lookup; + //unsigned int m_entry; + // unsigned int m_current_loaded_entry; + bool m_update; + + //int m_file_type; //0=gzopen, 1=fopen, 2=stringstream + float m_version; + + + }; +} #endif diff --git a/src/Store/BinaryStream.cpp b/src/Store/BinaryStream.cpp index 62834a8..7d3266b 100644 --- a/src/Store/BinaryStream.cpp +++ b/src/Store/BinaryStream.cpp @@ -1,5 +1,7 @@ #include +using namespace ToolFramework; + BinaryStream::BinaryStream(enum_endpoint endpoint){ m_endpoint=endpoint; diff --git a/src/Store/BinaryStream.h b/src/Store/BinaryStream.h index 1547b4f..b9dff6d 100644 --- a/src/Store/BinaryStream.h +++ b/src/Store/BinaryStream.h @@ -16,345 +16,348 @@ #endif #include //needed for inflate deflate -#define CHUNK 16384 // dito - -enum enum_endpoint { RAM , UNCOMPRESSED , POST_PRE_COMPRESS, COMPRESSED }; -enum enum_mode { READ , NEW , APPEND, UPDATE, READ_APPEND, NEW_READ }; -class BinaryStream : public SerialisableObject{ +namespace ToolFramework{ + +#define CHUNK 16384 // dito - public: + enum enum_endpoint { RAM , UNCOMPRESSED , POST_PRE_COMPRESS, COMPRESSED }; + enum enum_mode { READ , NEW , APPEND, UPDATE, READ_APPEND, NEW_READ }; - BinaryStream(enum_endpoint endpoint=RAM); - ~BinaryStream(); - bool Bopen(std::string filename, enum_mode method=UPDATE, enum_endpoint endpoint=POST_PRE_COMPRESS); - bool Bclose(bool Ignore_Post_Pre_compress=false); - bool Bwrite(const void* in, unsigned int size); - bool Bread(void* out, unsigned int size); - unsigned long int Btell(); - bool Bseek(unsigned int pos, int whence); - bool Print(); - bool Serialise(BinaryStream &bs); - std::string GetVersion(); - - enum_endpoint m_endpoint; - FILE* pfile; + class BinaryStream : public SerialisableObject{ + + public: + + BinaryStream(enum_endpoint endpoint=RAM); + ~BinaryStream(); + bool Bopen(std::string filename, enum_mode method=UPDATE, enum_endpoint endpoint=POST_PRE_COMPRESS); + bool Bclose(bool Ignore_Post_Pre_compress=false); + bool Bwrite(const void* in, unsigned int size); + bool Bread(void* out, unsigned int size); + unsigned long int Btell(); + bool Bseek(unsigned int pos, int whence); + bool Print(); + bool Serialise(BinaryStream &bs); + std::string GetVersion(); + + enum_endpoint m_endpoint; + FILE* pfile; #ifdef ZLIB - gzFile* gzfile; + gzFile* gzfile; #endif - std::string buffer; - bool m_write; - std::string m_file_name; - unsigned long int m_pos; - - enum_mode m_mode; //0=READ, 1==WRITE, 2==READ/APPEND - // 0=READ, 1==WRITE, 2==APPEND, 3 READ/WRITE, 4 READ/APPEND/ , 5 READ/OVEWRITE - // READ NEW APPEND UPDATE READ/APPEND , NEW/READ - - //gz read r, write w, append a - //fopen read r, write w, append a, read/write r+ (file must exist), read/write w+ (file doesnt exist/overwrite), read/append a+ - - //operator overloads - - bool operator<<(std::string& rhs){ - if(m_mode!=READ){ - bool ret=true; - unsigned int tmp=rhs.length(); - ret*=(*this) << tmp; - if(tmp) ret*=Bwrite(&(rhs[0]), tmp); - return ret; + std::string buffer; + bool m_write; + std::string m_file_name; + unsigned long int m_pos; + + enum_mode m_mode; //0=READ, 1==WRITE, 2==READ/APPEND + // 0=READ, 1==WRITE, 2==APPEND, 3 READ/WRITE, 4 READ/APPEND/ , 5 READ/OVEWRITE + // READ NEW APPEND UPDATE READ/APPEND , NEW/READ + + //gz read r, write w, append a + //fopen read r, write w, append a, read/write r+ (file must exist), read/write w+ (file doesnt exist/overwrite), read/append a+ + + //operator overloads + + bool operator<<(std::string& rhs){ + if(m_mode!=READ){ + bool ret=true; + unsigned int tmp=rhs.length(); + ret*=(*this) << tmp; + if(tmp) ret*=Bwrite(&(rhs[0]), tmp); + return ret; + } + else return false; } - else return false; - } - - bool operator>>(std::string& rhs){ - if(m_mode!=NEW && m_mode!=APPEND){ - bool ret=true; - unsigned int tmp=0; - ret*=(*this) >> tmp; - rhs.resize(tmp); - if(tmp) ret*=Bread(&(rhs[0]), tmp); - return ret; + + bool operator>>(std::string& rhs){ + if(m_mode!=NEW && m_mode!=APPEND){ + bool ret=true; + unsigned int tmp=0; + ret*=(*this) >> tmp; + rhs.resize(tmp); + if(tmp) ret*=Bread(&(rhs[0]), tmp); + return ret; + } + else return false; } - else return false; - } - - bool operator&(std::string& rhs){ - if(m_write) return (*this) << rhs; - else return (*this) >> rhs; - } - - bool operator<<(const std::string& rhs){ - if(m_mode!=READ){ - bool ret=true; - unsigned int tmp=rhs.length(); - ret*=(*this) << tmp; - if(tmp) ret*=Bwrite(&(rhs[0]), tmp); - return ret; + + bool operator&(std::string& rhs){ + if(m_write) return (*this) << rhs; + else return (*this) >> rhs; } - else return false; - } - - bool operator&(const std::string& rhs){ - if(m_write) return (*this) << rhs; - return false; - } - - - template bool operator<<(T& rhs){ - if(m_mode!=READ){ - if(check_base::value){ - SerialisableObject* tmp=reinterpret_cast(&rhs); - m_write=true; - return tmp->SerialiseWrapper(*this); + + bool operator<<(const std::string& rhs){ + if(m_mode!=READ){ + bool ret=true; + unsigned int tmp=rhs.length(); + ret*=(*this) << tmp; + if(tmp) ret*=Bwrite(&(rhs[0]), tmp); + return ret; } - else return Bwrite(&rhs, sizeof(T)); + else return false; } - else return false; - } - - - template bool operator>>(T& rhs){ - if(m_mode!=NEW && m_mode!=APPEND){ - if(check_base::value){ - SerialisableObject* tmp=reinterpret_cast(&rhs); - m_write=false; - return tmp->SerialiseWrapper(*this); - } - else return Bread(&rhs, sizeof(T)); + + bool operator&(const std::string& rhs){ + if(m_write) return (*this) << rhs; + return false; } - return false; - } - - - template bool operator&(T& rhs){ - if(m_write) return (*this) << rhs; - else return (*this) >> rhs; - } - - template bool operator<<(const T& rhs){ - if(m_mode!=READ){ - if(check_base::value){ - SerialisableObject* tmp=reinterpret_cast(&rhs); - m_write=true; - return tmp->SerialiseWrapper(*this); + + + template bool operator<<(T& rhs){ + if(m_mode!=READ){ + if(check_base::value){ + SerialisableObject* tmp=reinterpret_cast(&rhs); + m_write=true; + return tmp->SerialiseWrapper(*this); + } + else return Bwrite(&rhs, sizeof(T)); } - return Bwrite(&rhs, sizeof(T)); + else return false; } - else return false; - } - - template bool operator&(const T& rhs){ - if(m_write) return (*this) << rhs; - return false; - } - - - template bool operator<<(std::vector& rhs){ - if(m_mode!=READ){ - bool ret=true; - unsigned int tmp=rhs.size(); - ret*=(*this) << tmp; - if(tmp){ + + template bool operator>>(T& rhs){ + if(m_mode!=NEW && m_mode!=APPEND){ if(check_base::value){ - for(typename std::vector::iterator it=rhs.begin(); it!=rhs.end(); it++) ret*=(*this) << (*it); + SerialisableObject* tmp=reinterpret_cast(&rhs); + m_write=false; + return tmp->SerialiseWrapper(*this); } - else ret*=Bwrite(&(rhs[0]), tmp*sizeof(T)); + else return Bread(&rhs, sizeof(T)); } - return ret; + return false; } - else return false; - } - - template bool operator>>(std::vector& rhs){ - - if(m_mode!=NEW && m_mode!=APPEND){ - bool ret=true; - unsigned int tmp=0; - ret*=(*this) >> tmp; - rhs.resize(tmp); - if(tmp){ + + + template bool operator&(T& rhs){ + if(m_write) return (*this) << rhs; + else return (*this) >> rhs; + } + + template bool operator<<(const T& rhs){ + if(m_mode!=READ){ if(check_base::value){ - for(typename std::vector::iterator it=rhs.begin(); it!=rhs.end(); it++) ret*=(*this) >> (*it); + SerialisableObject* tmp=reinterpret_cast(&rhs); + m_write=true; + return tmp->SerialiseWrapper(*this); } - else ret*=Bread(&(rhs[0]), tmp*sizeof(T)); + return Bwrite(&rhs, sizeof(T)); } - return ret; + else return false; } - else return false; - } - - template bool operator&(std::vector& rhs){ - if(m_write) return (*this) << rhs; - else return (*this) >> rhs; - } - - bool operator<<(std::vector& rhs){ - if(m_mode!=READ){ - bool ret=true; - unsigned int tmp=rhs.size(); - ret*=(*this) << tmp; - for(unsigned int i=0; i bool operator&(const T& rhs){ + if(m_write) return (*this) << rhs; + return false; + } + + + template bool operator<<(std::vector& rhs){ + + if(m_mode!=READ){ + bool ret=true; + unsigned int tmp=rhs.size(); + ret*=(*this) << tmp; + if(tmp){ + if(check_base::value){ + for(typename std::vector::iterator it=rhs.begin(); it!=rhs.end(); it++) ret*=(*this) << (*it); + } + else ret*=Bwrite(&(rhs[0]), tmp*sizeof(T)); + } + return ret; } - return ret; + else return false; } - else return false; - } - - bool operator>>(std::vector& rhs){ - if(m_mode!=NEW && m_mode!=APPEND){ - bool ret=true; - unsigned int tmp=0; - ret*=(*this) >> tmp; - rhs.resize(tmp); - for(unsigned int i=0; i> rhs.at(i); + + template bool operator>>(std::vector& rhs){ + + if(m_mode!=NEW && m_mode!=APPEND){ + bool ret=true; + unsigned int tmp=0; + ret*=(*this) >> tmp; + rhs.resize(tmp); + if(tmp){ + if(check_base::value){ + for(typename std::vector::iterator it=rhs.begin(); it!=rhs.end(); it++) ret*=(*this) >> (*it); + } + else ret*=Bread(&(rhs[0]), tmp*sizeof(T)); + } + return ret; } - return ret; + else return false; } - else return false; - } - - bool operator&(std::vector& rhs){ - if(m_write) return (*this) << rhs; - else return (*this) >> rhs; - } - - template bool operator<<(std::map& rhs){ - if(m_mode!=READ){ - bool ret=true; - unsigned int tmp=rhs.size(); - ret*=(*this) << tmp; - for (typename std::map::iterator it=rhs.begin(); it!=rhs.end(); ++it){ - T key=it->first; - U value=it->second; - ret*=(*this) << key; - ret*=(*this) << value; + + template bool operator&(std::vector& rhs){ + + if(m_write) return (*this) << rhs; + else return (*this) >> rhs; + } + + bool operator<<(std::vector& rhs){ + if(m_mode!=READ){ + bool ret=true; + unsigned int tmp=rhs.size(); + ret*=(*this) << tmp; + for(unsigned int i=0; i bool operator>>(std::map& rhs){ - if(m_mode!=NEW && m_mode!=APPEND){ - bool ret=true; - unsigned int tmp=0; - ret*=(*this) >> tmp; - for (unsigned int i=0; i> key; - ret*=(*this) >> value; - rhs[key]=value; + + bool operator>>(std::vector& rhs){ + if(m_mode!=NEW && m_mode!=APPEND){ + bool ret=true; + unsigned int tmp=0; + ret*=(*this) >> tmp; + rhs.resize(tmp); + for(unsigned int i=0; i> rhs.at(i); + } + return ret; } - return ret; + else return false; } - else return false; - } - - template bool operator&(std::map& rhs){ - if(m_write) return (*this) << rhs; - else return (*this) >> rhs; - } - - template bool operator<<(std::deque& rhs){ - if(m_mode!=READ){ - bool ret=true; - unsigned int tmp=rhs.size(); - ret*=(*this) << tmp; - if(tmp){ - if(check_base::value){ - for(typename std::deque::iterator it=rhs.begin(); it!=rhs.end(); it++) ret*=(*this) << (*it); + + bool operator&(std::vector& rhs){ + if(m_write) return (*this) << rhs; + else return (*this) >> rhs; + } + + template bool operator<<(std::map& rhs){ + if(m_mode!=READ){ + bool ret=true; + unsigned int tmp=rhs.size(); + ret*=(*this) << tmp; + for (typename std::map::iterator it=rhs.begin(); it!=rhs.end(); ++it){ + T key=it->first; + U value=it->second; + ret*=(*this) << key; + ret*=(*this) << value; } - else ret*=Bwrite(&(rhs[0]), tmp*sizeof(T)); + return ret; } - return ret; + else return false; } - else return false; - } - - template bool operator>>(std::deque& rhs){ - if(m_mode!=NEW && m_mode!=APPEND){ - bool ret=true; - unsigned int tmp=0; - ret*=(*this) >> tmp; - rhs.resize(tmp); - if(tmp){ - if(check_base::value){ - for(typename std::deque::iterator it=rhs.begin(); it!=rhs.end(); it++) ret*=(*this) >> (*it); + + template bool operator>>(std::map& rhs){ + if(m_mode!=NEW && m_mode!=APPEND){ + bool ret=true; + unsigned int tmp=0; + ret*=(*this) >> tmp; + for (unsigned int i=0; i> key; + ret*=(*this) >> value; + rhs[key]=value; } - else ret*=Bread(&(rhs[0]), tmp*sizeof(T)); + return ret; } - return ret; + else return false; } - else return false; - } - - template bool operator&(std::deque& rhs){ - if(m_write) return(*this) << rhs; - else return(*this) >> rhs; - } - - bool operator<<(std::deque& rhs){ - if(m_mode!=READ){ - bool ret=true; - unsigned int tmp=rhs.size(); - ret*=(*this) << tmp; - for(unsigned int i=0; i bool operator&(std::map& rhs){ + if(m_write) return (*this) << rhs; + else return (*this) >> rhs; + } + + template bool operator<<(std::deque& rhs){ + if(m_mode!=READ){ + bool ret=true; + unsigned int tmp=rhs.size(); + ret*=(*this) << tmp; + if(tmp){ + if(check_base::value){ + for(typename std::deque::iterator it=rhs.begin(); it!=rhs.end(); it++) ret*=(*this) << (*it); + } + else ret*=Bwrite(&(rhs[0]), tmp*sizeof(T)); + } + return ret; } - return ret; + else return false; } - else return false; - } - - bool operator>>(std::deque& rhs){ - if(m_mode!=NEW && m_mode!=APPEND){ - bool ret=true; - unsigned int tmp=0; - ret*=(*this) >> tmp; - rhs.resize(tmp); - for(unsigned int i=0; i> rhs.at(i); + + template bool operator>>(std::deque& rhs){ + if(m_mode!=NEW && m_mode!=APPEND){ + bool ret=true; + unsigned int tmp=0; + ret*=(*this) >> tmp; + rhs.resize(tmp); + if(tmp){ + if(check_base::value){ + for(typename std::deque::iterator it=rhs.begin(); it!=rhs.end(); it++) ret*=(*this) >> (*it); + } + else ret*=Bread(&(rhs[0]), tmp*sizeof(T)); + } + return ret; } - return ret; + else return false; } - else return false; - } - - bool operator&(std::deque& rhs){ - if(m_write) return (*this) << rhs; - else return (*this) >> rhs; - } - - - private: - - int def(FILE *source, FILE *dest, int level); - int inf(FILE *source, FILE *dest); - void zerr(int ret); - - template struct Host{ - operator B*() const; - operator D*(); + template bool operator&(std::deque& rhs){ + if(m_write) return(*this) << rhs; + else return(*this) >> rhs; + } + + bool operator<<(std::deque& rhs){ + if(m_mode!=READ){ + bool ret=true; + unsigned int tmp=rhs.size(); + ret*=(*this) << tmp; + for(unsigned int i=0; i>(std::deque& rhs){ + if(m_mode!=NEW && m_mode!=APPEND){ + bool ret=true; + unsigned int tmp=0; + ret*=(*this) >> tmp; + rhs.resize(tmp); + for(unsigned int i=0; i> rhs.at(i); + } + return ret; + } + else return false; + } + + bool operator&(std::deque& rhs){ + if(m_write) return (*this) << rhs; + else return (*this) >> rhs; + } + + + private: + + int def(FILE *source, FILE *dest, int level); + int inf(FILE *source, FILE *dest); + void zerr(int ret); + + template struct Host{ + + operator B*() const; + operator D*(); + + }; + + + template struct check_base { + template + static short check(D*, T); + static char check(B*, int); + + static const bool value = sizeof(check(Host(), int())) == sizeof(short); + }; - }; - - - template struct check_base { - template - static short check(D*, T); - static char check(B*, int); - static const bool value = sizeof(check(Host(), int())) == sizeof(short); - }; - - /* derived: @@ -378,7 +381,8 @@ not derrived: */ -}; + }; +} #endif diff --git a/src/Store/PointerWrapper.h b/src/Store/PointerWrapper.h index afa67f9..f6379b2 100644 --- a/src/Store/PointerWrapper.h +++ b/src/Store/PointerWrapper.h @@ -1,42 +1,45 @@ #ifndef POINTERWRAPPER_H #define POINTERWRAPPER_H +namespace ToolFramework{ -/** - * \class PointerWrapperBase - * - * This class is used to wrap pointers stored in a BoostStore. It gives a generic abstract base class to store pointers under - * - * $Author: B.Richards $ - * $Date: 2019/05/28 10:44:00 $ - */ - -class PointerWrapperBase{ - - public: - - PointerWrapperBase(){} ///< Simple constructor - virtual ~PointerWrapperBase(){} ///< virtual destructor + /** + * \class PointerWrapperBase + * + * This class is used to wrap pointers stored in a BoostStore. It gives a generic abstract base class to store pointers under + * + * $Author: B.Richards $ + * $Date: 2019/05/28 10:44:00 $ + */ -}; - -/** - * \class PointerWrapper - * - * Teplated derived class of PointerWrapperBase to provide a plymorphic interface to stored poitner variables. - * - * $Author: B.Richards $ - * $Date: 2019/05/28 10:44:00 $ - */ - -template class PointerWrapper : public PointerWrapperBase { + class PointerWrapperBase{ + + public: + + PointerWrapperBase(){} ///< Simple constructor + virtual ~PointerWrapperBase(){} ///< virtual destructor + + }; - public: + /** + * \class PointerWrapper + * + * Teplated derived class of PointerWrapperBase to provide a plymorphic interface to stored poitner variables. + * + * $Author: B.Richards $ + * $Date: 2019/05/28 10:44:00 $ + */ - T* pointer; ///< Pointer to the orignial obkect - PointerWrapper(T* inpointer): pointer(inpointer){} ///< Constructor @param inpointer The pointer to be wrapped. - ~PointerWrapper(){delete pointer; pointer=0;}; ///< Destructor. + template class PointerWrapper : public PointerWrapperBase { + + public: + + T* pointer; ///< Pointer to the orignial obkect + PointerWrapper(T* inpointer): pointer(inpointer){} ///< Constructor @param inpointer The pointer to be wrapped. + ~PointerWrapper(){delete pointer; pointer=0;}; ///< Destructor. + + }; -}; +} #endif diff --git a/src/Store/SerialisableObject.h b/src/Store/SerialisableObject.h index 4df37e8..41b675b 100644 --- a/src/Store/SerialisableObject.h +++ b/src/Store/SerialisableObject.h @@ -3,51 +3,54 @@ #include -/** - * \class SerialisableObject - * - * An abstract base class for sustom calsses to inherit from to ensure version and type information are present, as well as a Print function and some form of sereialisation. -* -* $Author: B.Richards $ -* $Date: 2019/05/28 10:44:00 $ -*/ +namespace ToolFramework{ -//class archive; -class BinaryStream; - -class SerialisableObject{ - - - public: - virtual ~SerialisableObject(){}; - bool SerialiseWrapper(BinaryStream &bs); - virtual bool Serialise(BinaryStream &bs)=0; - virtual std::string GetVersion()=0; - virtual bool Print()=0; ///< Simple virtual Pritn function to ensure inhereted classes have one - // virtual ~SerialisableObject(){}; ///< Destructor - //bool m_serialise; ///< Denotes if the calss should be serialised or not when added to a BoostStore. - //protected: - - //std::string type; ///< String to store type of Tool - // std::string m_version; ///< String to store version of Tool - /** - Simple Boost serialise method to serialise the membervariables of a custom class. This shuld be expanded to include the custom classes variables - @param ar Boost archive. - @param version of the archive. + * \class SerialisableObject + * + * An abstract base class for sustom calsses to inherit from to ensure version and type information are present, as well as a Print function and some form of sereialisation. + * + * $Author: B.Richards $ + * $Date: 2019/05/28 10:44:00 $ */ - /* template void serialize(Archive & ar, const unsigned int version){ - if(serialise){ - ar & type; - ar & version; - } - } - */ - - -}; - + //class archive; + class BinaryStream; + + class SerialisableObject{ + + + public: + virtual ~SerialisableObject(){}; + bool SerialiseWrapper(BinaryStream &bs); + virtual bool Serialise(BinaryStream &bs)=0; + virtual std::string GetVersion()=0; + virtual bool Print()=0; ///< Simple virtual Pritn function to ensure inhereted classes have one + // virtual ~SerialisableObject(){}; ///< Destructor + //bool m_serialise; ///< Denotes if the calss should be serialised or not when added to a BoostStore. + //protected: + + //std::string type; ///< String to store type of Tool + // std::string m_version; ///< String to store version of Tool + + /** + Simple Boost serialise method to serialise the membervariables of a custom class. This shuld be expanded to include the custom classes variables + @param ar Boost archive. + @param version of the archive. + */ + /* template void serialize(Archive & ar, const unsigned int version){ + if(serialise){ + ar & type; + ar & version; + } + } + */ + + + + }; + +} #endif diff --git a/src/Store/Store.cpp b/src/Store/Store.cpp index 783f587..fcd692d 100644 --- a/src/Store/Store.cpp +++ b/src/Store/Store.cpp @@ -1,5 +1,6 @@ #include "Store.h" +using namespace ToolFramework; Store::Store(){} diff --git a/src/Store/Store.h b/src/Store/Store.h index 1426b8c..75e5fc7 100644 --- a/src/Store/Store.h +++ b/src/Store/Store.h @@ -8,121 +8,123 @@ #include #include - -/** - * \class Store - * - * This class Is a dynamic data storeage class and can be used to store variables of any type listed by ASCII key. The storage of the varaible is in ASCII, so is inefficent for large numbers of entries. - * - * $Author: B.Richards $ - * $Date: 2019/05/28 10:44:00 $ - */ - -class Store{ - - public: - - Store(); ////< Sinple constructor - - bool Initialise(std::string filename); ///< Initialises Store by reading in entries from an ASCII text file, when each line is a variable and its value in key value pairs. @param filename The filepath and name to the input file. - void JsonParser(std::string input); ///< Converts a flat JSON formatted string to Store entries in the form of key value pairs. @param input The input flat JSON string. - void Print(); ///< Prints the contents of the Store. - void Delete(); ///< Deletes all entries in the Store. - bool Has(std::string key); /// Keys(); //returns a vector of the keys +namespace ToolFramework{ /** - Templated getter function for sore content. Assignment is templated and via reference. - @param name The ASCII key that the variable in the Store is stored with. - @param out The variable to fill with the value. - @return Return value is true if varaible exists in the Store and correctly assigned to out and false if not. - */ - template bool Get(std::string name,T &out){ - - if(m_variables.count(name)>0){ - - std::stringstream stream(m_variables[name]); - stream>>out; - return !stream.fail(); + * \class Store + * + * This class Is a dynamic data storeage class and can be used to store variables of any type listed by ASCII key. The storage of the varaible is in ASCII, so is inefficent for large numbers of entries. + * + * $Author: B.Richards $ + * $Date: 2019/05/28 10:44:00 $ + */ + + class Store{ + + public: + + Store(); ////< Sinple constructor + + bool Initialise(std::string filename); ///< Initialises Store by reading in entries from an ASCII text file, when each line is a variable and its value in key value pairs. @param filename The filepath and name to the input file. + void JsonParser(std::string input); ///< Converts a flat JSON formatted string to Store entries in the form of key value pairs. @param input The input flat JSON string. + void Print(); ///< Prints the contents of the Store. + void Delete(); ///< Deletes all entries in the Store. + bool Has(std::string key); /// Keys(); //returns a vector of the keys + + /** + Templated getter function for sore content. Assignment is templated and via reference. + @param name The ASCII key that the variable in the Store is stored with. + @param out The variable to fill with the value. + @return Return value is true if varaible exists in the Store and correctly assigned to out and false if not. + */ + template bool Get(std::string name,T &out){ + + if(m_variables.count(name)>0){ + + std::stringstream stream(m_variables[name]); + stream>>out; + return !stream.fail(); + } + + return false; + } - return false; - - } - -/** - getter function for string content.. - @param name The ASCII key that the variable in the Store is stored with. - @param out The variable to fill with the value. - @return Return value is true if varaible exists in the Store and correctly assigned to out and false if not. - */ - bool Get(std::string name, std::string &out); - - - /** - Templated getter function for sore content. - @param name The ASCII key that the variable in the Store is stored with. - @return Return value is default copiler costructed value if not true (note: no checking exists) - */ - template T Get(std::string name){ - - T tmp; - if(!Get(name,tmp)) std::cout<<"\033[38;5;196mERROR: Store doesnt hold value \""< void Set(std::string name,T in){ - std::stringstream stream; - stream< void operator>>(T& obj){ - - std::stringstream stream; - stream<<"{"; - bool first=true; - for (std::map::iterator it=m_variables.begin(); it!=m_variables.end(); ++it){ - if (!first) stream<<","; - stream<<"\""<first<<"\":\""<< it->second<<"\""; - first=false; + /** + getter function for string content.. + @param name The ASCII key that the variable in the Store is stored with. + @param out The variable to fill with the value. + @return Return value is true if varaible exists in the Store and correctly assigned to out and false if not. + */ + bool Get(std::string name, std::string &out); + + + /** + Templated getter function for sore content. + @param name The ASCII key that the variable in the Store is stored with. + @return Return value is default copiler costructed value if not true (note: no checking exists) + */ + template T Get(std::string name){ + + T tmp; + if(!Get(name,tmp)) std::cout<<"\033[38;5;196mERROR: Store doesnt hold value \""<::const_iterator begin() { return m_variables.begin(); } - std::map::const_iterator end() { return m_variables.end(); } - - - private: - + + /** + Templated setter function to assign vairables in the Store. + @param name The key to be used to store and reference the variable in the Store. + @param in the varaible to be stored. + */ + template void Set(std::string name,T in){ + std::stringstream stream; + stream< void operator>>(T& obj){ + + std::stringstream stream; + stream<<"{"; + bool first=true; + for (std::map::iterator it=m_variables.begin(); it!=m_variables.end(); ++it){ + if (!first) stream<<","; + stream<<"\""<first<<"\":\""<< it->second<<"\""; + first=false; + } + stream<<"}"; + + obj=stream.str(); + + } + + std::map::const_iterator begin() { return m_variables.begin(); } + std::map::const_iterator end() { return m_variables.end(); } + + + private: + + + std::map m_variables; + + }; - std::map m_variables; - -}; - +} #endif diff --git a/src/Tool/Tool.h b/src/Tool/Tool.h index 9869311..1c3a925 100644 --- a/src/Tool/Tool.h +++ b/src/Tool/Tool.h @@ -9,46 +9,50 @@ class DataModel; -/** - * \class Tool - * - * Abstract base class for Tools to inherit from. This allows a polymphic interface for the factor to use. -* -* $Author: B.Richards $ -* $Date: 2019/05/28 10:44:00 $ -*/ - -class Tool{ - - public: - - Tool(){}; - virtual bool Initialise(std::string configfile,DataModel &data)=0; ///< virtual Initialise function that reads in the assigned config file and optain DataMoodel reference @param configfile Path and name of config file to read in. @param data Reference to DataModel. - virtual bool Execute()=0; ///< Virtual Execute function. - virtual bool Finalise()=0; ///< Virtual Finalise function. - virtual ~Tool(){}; ///< virtual destructor. - std::string Getname() {return m_tool_name;}; - void SetName(std::string name) {m_tool_name=name;}; - - protected: - - std::string m_tool_name; - Store m_variables; ///< Store used to store configuration varaibles - DataModel* m_data; ///< Pointer to transiant DataModel class - Logging* m_log; ///< Pointer to logging class - int m_verbose; ///< verbosity variable for direct logging level - MsgL ML(int messagelevel) {return MsgL(messagelevel,m_verbose);} ///< Function for setting logging level instream @param messagelevel the verboisty level at which to show the message. Checked against internal verbosity level. - void MLC() {*(m_log)< void Log(T message, int messagelevel, int verbosity){m_log->Log(message,messagelevel,verbosity);} - template void Log(T message, int messagelevel=0){m_log->Log(message,messagelevel,m_verbose);} ///< Logging fuction for printouts. @param message Templated message string. @param messagelevel The verbosity level at which to show the message. Checked against internal verbosity level - - - private: - - - - - -}; +namespace ToolFramework{ + + /** + * \class Tool + * + * Abstract base class for Tools to inherit from. This allows a polymphic interface for the factor to use. + * + * $Author: B.Richards $ + * $Date: 2019/05/28 10:44:00 $ + */ + + class Tool{ + + public: + + Tool(){}; + virtual bool Initialise(std::string configfile,DataModel &data)=0; ///< virtual Initialise function that reads in the assigned config file and optain DataMoodel reference @param configfile Path and name of config file to read in. @param data Reference to DataModel. + virtual bool Execute()=0; ///< Virtual Execute function. + virtual bool Finalise()=0; ///< Virtual Finalise function. + virtual ~Tool(){}; ///< virtual destructor. + std::string Getname() {return m_tool_name;}; + void SetName(std::string name) {m_tool_name=name;}; + + protected: + + std::string m_tool_name; + Store m_variables; ///< Store used to store configuration varaibles + DataModel* m_data; ///< Pointer to transiant DataModel class + Logging* m_log; ///< Pointer to logging class + int m_verbose; ///< verbosity variable for direct logging level + MsgL ML(int messagelevel) {return MsgL(messagelevel,m_verbose);} ///< Function for setting logging level instream @param messagelevel the verboisty level at which to show the message. Checked against internal verbosity level. + void MLC() {*(m_log)< void Log(T message, int messagelevel, int verbosity){m_log->Log(message,messagelevel,verbosity);} + template void Log(T message, int messagelevel=0){m_log->Log(message,messagelevel,m_verbose);} ///< Logging fuction for printouts. @param message Templated message string. @param messagelevel The verbosity level at which to show the message. Checked against internal verbosity level + + + private: + + + + + + }; + +} #endif diff --git a/src/ToolChain/ToolChain.cpp b/src/ToolChain/ToolChain.cpp index 82a17b9..1e47122 100644 --- a/src/ToolChain/ToolChain.cpp +++ b/src/ToolChain/ToolChain.cpp @@ -1,5 +1,7 @@ #include "ToolChain.h" +using namespace ToolFramework; + ToolChain::ToolChain(std::string configfile, DataModel* data_model, int argc, char* argv[]){ m_data=reinterpret_cast(data_model); diff --git a/src/ToolChain/ToolChain.h b/src/ToolChain/ToolChain.h index 2594c47..08d61cf 100644 --- a/src/ToolChain/ToolChain.h +++ b/src/ToolChain/ToolChain.h @@ -19,99 +19,104 @@ class DataModel; -/** - * \struct ToolChainargs - * - * Simple struct to pass thread initalisation variables to Interactive ToolChain thread -* -* $Author: B.Richards $ -* $Date: 2019/05/28 10:44:00 $ -*/ - -struct ToolChainargs{ - - ToolChainargs(){}; - - bool *msgflag; ///< Message flag used to indiacte if a new interactive command has been submitted to the interactive thread and needs execution on the main thread. - std::string command; - -}; - -/** - * \class ToolChain - * - * This class holds a dynamic list of Tools which can be Initialised, Executed and Finalised to perform program operation. Large number of options in terms of run modes and setting can be assigned. -* -* $Author: B.Richards $ -* $Date: 2019/05/28 10:44:00 $ -*/ - -class ToolChain{ +namespace ToolFramework{ - public: - - ToolChain(){}; - ToolChain(std::string configfile, DataModel* data_model, int argc=0, char* argv[]=0); ///< Constructor that obtains all of the configuration varaibles from an input file. @param configfile The path and name of the config file to read configuration values from. - /** - Constructor with explicit configuration variables passed as arguments. - @param verbose The verbosity level of the ToolChain. The higher the number the more explicit the print outs. 0 = silent apart from errors. - @param errorlevel The behavior that occurs when the ToolChain encounters an error. 0 = do not exit for both handeled and unhandeled errors, 1 = exit on unhandeled errors only, 2 = exit on handeled and unhandeled errors. - @param log_interactive sets the logging class to use standard output and error to screen - @param log_local sets the logging class to redirect standard output and error to disk -logmode Where log printouts should be forwarded too. "Interactive" = cout, "Remote" = send to a remote logging system, "local" = ouput logs to a file. - @param log_local_path The file path and name of where to store logs if in Local logging mode. - @param log_split_files when loggign to local file whether to split standard output and standard error into differnt files - @param in_data_model option to specify an external data modle for use in ToolChain. + * \struct ToolChainargs + * + * Simple struct to pass thread initalisation variables to Interactive ToolChain thread + * + * $Author: B.Richards $ + * $Date: 2019/05/28 10:44:00 $ */ - ToolChain(int verbose, int errorlevel=0, bool log_interactive=true, bool log_local=false, std::string log_local_path="./log", bool log_split_files=false, DataModel* in_data_model=0); - //verbosity: true= print out status messages , false= print only error messages; - //errorlevels: 0= do not exit; error 1= exit if unhandeled error ; exit 2= exit on handeled and unhandeled errors; - virtual ~ToolChain(); - bool Add(std::string name, Tool *tool,std::string configfile=""); ///< Add a Tool to the ToolChain. @param name The name used in logs when reffering to the Tool. @param tool A pointer to the tool to be added to the ToolChain. @param configfile The configuration file path and name to be passed to the Tool. - int Initialise(); ///< Initialise all Tools in the ToolChain sequentially. - int Execute(int repeates=1); ///< Execute all Tools in the ToolChain sequentially. @param repeates How many times to run sequential Execute loop. - int Finalise(); ///< Finalise all Tools in the ToolCahin sequentially. - void Interactive(); ///< Start interactive thread to accept commands and run ToolChain in interactive mode. - bool LoadTools(std::string filename); - DataModelBase* m_data; ///< Direct access to transient data model class of the Tools in the ToolChain. This allows direct initialisation and copying of variables. - - protected: - - virtual void Init(); - void Inline(); - - static void *InteractiveThread(void* arg); - std::string ExecuteCommand(std::string connand); - - //Tools configs and data - std::vector m_tools; - std::vector m_toolnames; - std::vector m_configfiles; - //conf variables - int m_verbose; - int m_errorlevel; - bool m_log_interactive; - bool m_log_local; - bool m_log_split_files; - std::string m_log_local_path; - bool m_interactive; - int m_inline; - bool m_recover; + struct ToolChainargs{ + + ToolChainargs(){}; + + bool *msgflag; ///< Message flag used to indiacte if a new interactive command has been submitted to the interactive thread and needs execution on the main thread. + std::string command; + + }; - //status variables - bool exeloop; - unsigned long execounter; - bool Initialised; - bool Finalised; - bool paused; - Logging* m_log; - - //socket coms and threading variables - pthread_t thread[1]; - bool msgflag; - -}; + /** + * \class ToolChain + * + * This class holds a dynamic list of Tools which can be Initialised, Executed and Finalised to perform program operation. Large number of options in terms of run modes and setting can be assigned. + * + * $Author: B.Richards $ + * $Date: 2019/05/28 10:44:00 $ + */ + + class ToolChain{ + + public: + + ToolChain(){}; + ToolChain(std::string configfile, DataModel* data_model, int argc=0, char* argv[]=0); ///< Constructor that obtains all of the configuration varaibles from an input file. @param configfile The path and name of the config file to read configuration values from. + + /** + Constructor with explicit configuration variables passed as arguments. + @param verbose The verbosity level of the ToolChain. The higher the number the more explicit the print outs. 0 = silent apart from errors. + @param errorlevel The behavior that occurs when the ToolChain encounters an error. 0 = do not exit for both handeled and unhandeled errors, 1 = exit on unhandeled errors only, 2 = exit on handeled and unhandeled errors. + @param log_interactive sets the logging class to use standard output and error to screen + @param log_local sets the logging class to redirect standard output and error to disk + logmode Where log printouts should be forwarded too. "Interactive" = cout, "Remote" = send to a remote logging system, "local" = ouput logs to a file. + @param log_local_path The file path and name of where to store logs if in Local logging mode. + @param log_split_files when loggign to local file whether to split standard output and standard error into differnt files + @param in_data_model option to specify an external data modle for use in ToolChain. + */ + ToolChain(int verbose, int errorlevel=0, bool log_interactive=true, bool log_local=false, std::string log_local_path="./log", bool log_split_files=false, DataModel* in_data_model=0); + //verbosity: true= print out status messages , false= print only error messages; + //errorlevels: 0= do not exit; error 1= exit if unhandeled error ; exit 2= exit on handeled and unhandeled errors; + virtual ~ToolChain(); + bool Add(std::string name, Tool *tool,std::string configfile=""); ///< Add a Tool to the ToolChain. @param name The name used in logs when reffering to the Tool. @param tool A pointer to the tool to be added to the ToolChain. @param configfile The configuration file path and name to be passed to the Tool. + int Initialise(); ///< Initialise all Tools in the ToolChain sequentially. + int Execute(int repeates=1); ///< Execute all Tools in the ToolChain sequentially. @param repeates How many times to run sequential Execute loop. + int Finalise(); ///< Finalise all Tools in the ToolCahin sequentially. + void Interactive(); ///< Start interactive thread to accept commands and run ToolChain in interactive mode. + bool LoadTools(std::string filename); + DataModelBase* m_data; ///< Direct access to transient data model class of the Tools in the ToolChain. This allows direct initialisation and copying of variables. + + protected: + + virtual void Init(); + void Inline(); + + static void *InteractiveThread(void* arg); + std::string ExecuteCommand(std::string connand); + + //Tools configs and data + std::vector m_tools; + std::vector m_toolnames; + std::vector m_configfiles; + + //conf variables + int m_verbose; + int m_errorlevel; + bool m_log_interactive; + bool m_log_local; + bool m_log_split_files; + std::string m_log_local_path; + bool m_interactive; + int m_inline; + bool m_recover; + + //status variables + bool exeloop; + unsigned long execounter; + bool Initialised; + bool Finalised; + bool paused; + Logging* m_log; + + //socket coms and threading variables + pthread_t thread[1]; + bool msgflag; + + }; + + +} #endif diff --git a/src/main.cpp b/src/main.cpp index 6ae6d15..8ac0e76 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3,20 +3,22 @@ #include "DataModel.h" //#include "DummyTool.h" +using namespace ToolFramework; + int main(int argc, char* argv[]){ std::string config_file; if (argc==1)config_file="configfiles/Dummy/ToolChainConfig"; else config_file=argv[1]; -DataModel* data_model = new DataModel(); + DataModel* data_model = new DataModel(); ToolChain tools(config_file, data_model, argc, argv); - - + + //DummyTool dummytool; - + //tools.Add("DummyTool",&dummytool,"configfiles/DummyToolConfig"); - + //int portnum=24000; // tools.Remote(portnum); //tools.Interactive(); From d3b9dde44cee09f3bdabbed71645cbc505103cd6 Mon Sep 17 00:00:00 2001 From: brichards Date: Tue, 16 Jan 2024 22:11:17 +0000 Subject: [PATCH 03/18] corrected datamodel base name --- Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index a11b3e7..b38435c 100644 --- a/Makefile +++ b/Makefile @@ -15,8 +15,8 @@ TempToolsLib = Includes=-I $(SOURCEDIR)/include/ -Libs=-L $(SOURCEDIR)/lib/ -lStore -lLogging -lToolchain -lTempDataModelBase -lTempDataModel -lTempTools -lpthread -LIBRARIES=lib/libStore.so lib/libLogging.so lib/libToolChain.so lib/libTempDataModelbase.so lib/libTempDataModel.so lib/libTempTools.so +Libs=-L $(SOURCEDIR)/lib/ -lStore -lLogging -lToolchain -lDataModelBase -lTempDataModel -lTempTools -lpthread +LIBRARIES=lib/libStore.so lib/libLogging.so lib/libToolChain.so lib/libDataModelBase.so lib/libTempDataModel.so lib/libTempTools.so HEADERS:=$(patsubst %.h, include/%.h, $(filter %.h, $(subst /, ,$(patsubst src/%.h, include/%.h, $(wildcard src/*/*.h) )))) TempDataModelHEADERS:=$(patsubst %.h, include/%.h, $(filter %.h, $(subst /, ,$(patsubst src/%.h, include/%.h, $(wildcard DataModel/*.h))))) MyToolHEADERS:=$(patsubst %.h, include/%.h, $(filter %.h, $(subst /, ,$(patsubst src/%.h, include/%.h, $(wildcard UserTools/*/*.h) $(wildcard UserTools/*.h))))) @@ -61,7 +61,7 @@ lib/libLogging.so: $(patsubst %.cpp, %.o , $(wildcard src/Logging/*.cpp)) | $(HE @echo -e "\e[38;5;201m\n*************** Making " $@ "****************\e[0m" g++ $(CXXFLAGS) --shared $^ -o $@ $(Includes) -lib/libTempDataModelbase.so: $(patsubst %.cpp, %.o , $(wildcard src/DataModelBase/*.cpp)) | $(HEADERS) +lib/libDataModelBase.so: $(patsubst %.cpp, %.o , $(wildcard src/DataModelBase/*.cpp)) | $(HEADERS) @echo -e "\e[38;5;201m\n*************** Making " $@ "****************\e[0m" g++ $(CXXFLAGS) --shared $^ -o $@ $(Includes) From 7f6023d0cc5a34198f71afd3eb9f6b9533ff5bb7 Mon Sep 17 00:00:00 2001 From: brichards Date: Tue, 16 Jan 2024 22:24:55 +0000 Subject: [PATCH 04/18] added missing DataModelBase files --- src/DataModelBase/DataModelBase.cpp | 7 +++ src/DataModelBase/DataModelBase.h | 54 ++++++++++++++++++ src/DataModelBase/README.md | 8 +++ src/DataModelBase/Utilities.cpp | 73 +++++++++++++++++++++++++ src/DataModelBase/Utilities.h | 85 +++++++++++++++++++++++++++++ 5 files changed, 227 insertions(+) create mode 100644 src/DataModelBase/DataModelBase.cpp create mode 100644 src/DataModelBase/DataModelBase.h create mode 100644 src/DataModelBase/README.md create mode 100644 src/DataModelBase/Utilities.cpp create mode 100644 src/DataModelBase/Utilities.h diff --git a/src/DataModelBase/DataModelBase.cpp b/src/DataModelBase/DataModelBase.cpp new file mode 100644 index 0000000..75ad356 --- /dev/null +++ b/src/DataModelBase/DataModelBase.cpp @@ -0,0 +1,7 @@ +#include "DataModelBase.h" + +using namespace ToolFramework; + +DataModelBase::DataModelBase(){ Log=0;} + + diff --git a/src/DataModelBase/DataModelBase.h b/src/DataModelBase/DataModelBase.h new file mode 100644 index 0000000..b68e966 --- /dev/null +++ b/src/DataModelBase/DataModelBase.h @@ -0,0 +1,54 @@ +#ifndef DATAMODELBASE_H +#define DATAMODELBASE_H + +#include +#include +#include +#include "Utilities.h" + +#include "Store.h" +#include "BStore.h" +#include "Logging.h" + +namespace ToolFramework{ + + + /** + * \class DataModelBase + * + * This class Is a transient data model class for your Tools within the ToolChain. If Tools need to comunicate they pass all data objects through the data model. There fore inter tool data objects should be deffined in this class. + * + * + * $Author: B.Richards $ + * $Date: 2019/05/26 18:34:00 $ + * + */ + + class DataModelBase { + + + public: + + DataModelBase(); ///< Simple constructor + + Logging *Log; ///< Log class pointer for use in Tools, it can be used to send messages which can have multiple error levels and destination end points + + Store vars; ///< This Store can be used for any variables. It is an inefficent ascii based storage and command line arguments will be placed in here along with ToolChain variables + BStore CStore; ///< This is a more efficent binary Store that can be used to store a dynamic set of inter Tool variables, very useful for constants and and flags hence the name CStore + std::map Stores; ///< This is a map of named BStore pointers which can be deffined to hold a nammed collection of any type of BStore. It is usefull to store data collections that needs subdividing into differnt stores. + + + + protected: + + + + + + + }; + +} + + +#endif diff --git a/src/DataModelBase/README.md b/src/DataModelBase/README.md new file mode 100644 index 0000000..c91735a --- /dev/null +++ b/src/DataModelBase/README.md @@ -0,0 +1,8 @@ +#Data Model +************************* + +Data Model Class can be defined how ever the User requires. A Store is provided which ineficently maps variables to string lkeys via conversion to stringstream and can be used for debuging or other useful vairables. + +A TTree map with getter and setter functions is provided and can be uncommented if required. + + diff --git a/src/DataModelBase/Utilities.cpp b/src/DataModelBase/Utilities.cpp new file mode 100644 index 0000000..6c80c6b --- /dev/null +++ b/src/DataModelBase/Utilities.cpp @@ -0,0 +1,73 @@ +#include + +using namespace ToolFramework; + +Utilities::Utilities(){ + Threads.clear(); +} + + +Thread_args* Utilities::CreateThread(std::string ThreadName, void (*func)(Thread_args*), Thread_args* args){ + + if(Threads.count(ThreadName)==0){ + + if(args==0) args = new Thread_args(); + + args->ThreadName=ThreadName; + args->func=func; + args->running=true; + + pthread_create(&(args->thread), NULL, Utilities::Thread, args); + + Threads[ThreadName]=args; + +} + + else args=0; + + return args; + +} + + +void *Utilities::Thread(void *arg){ + + Thread_args *args = static_cast(arg); + + while (!args->kill){ + + if(args->running) args->func(args ); + else usleep(100); + + } + + pthread_exit(NULL); + +} + + +bool Utilities::KillThread(Thread_args* &args){ + + bool ret=false; + + if(args){ + + args->running=false; + args->kill=true; + + pthread_join(args->thread, NULL); + //delete args; + //args=0; + + } + + return ret; + +} + +bool Utilities::KillThread(std::string ThreadName){ + + return KillThread(Threads[ThreadName]); + +} + diff --git a/src/DataModelBase/Utilities.h b/src/DataModelBase/Utilities.h new file mode 100644 index 0000000..38fa629 --- /dev/null +++ b/src/DataModelBase/Utilities.h @@ -0,0 +1,85 @@ +#ifndef UTILITIES_H +#define UTILITIES_H + +#include +#include +#include +#include +#include +#include + +namespace ToolFramework{ + + /** + * \struct DataModelThread_args + * + * This is both an base class for any thread argument struct used in the tool threaded Tool templates. + Effectivly this acts as a place to put variable that are specfic to that thread and can be used as a place to transfer variables from the main thread to sub threads. + * + * + * $Author: B.Richards $ + * $Date: 2019/05/26 18:34:00 $ + * + */ + + struct Thread_args{ + + Thread_args(){ ///< Simple constructor + kill=false; + running=false; + } + + virtual ~Thread_args(){ ///< virtual constructor + running =false; + kill=true; + } + + std::string ThreadName; ///< name of thread (deffined at creation) + void (*func)(Thread_args*); ///< function pointer to thread with args + pthread_t thread; ///< Simple constructor underlying thread that interface is built ontop of + bool running; ///< Bool flag to tell the thread to run (if not set thread goes into wait cycle + bool kill; ///< Bool flay used to kill the thread + + }; + + + /** + * \class Utilities + * + * This class can be instansiated in a Tool and provides some helpful threading, dynamic socket descovery and promotion functionality + * + * + * $Author: B.Richards $ + * $Date: 2019/05/26 18:34:00 $ + * + */ + + class Utilities{ + + public: + + Utilities(); ///< Simple constructor + Thread_args* CreateThread(std::string ThreadName, void (*func)(Thread_args*), Thread_args* args); ///< Create a thread with more complicated data exchange definned by arguments + bool KillThread(Thread_args* &args); ///< Kill a thread assosiated to args + bool KillThread(std::string ThreadName); ///< Kill a thread by name + + template bool KillThread(T* pointer){ + + Thread_args* tmp=pointer; + return KillThread(tmp); + + } ///< Kill a thread with args that inheirt form base Thread_args + + + + protected: + + static void* Thread(void *arg); ///< Thread with args + std::map Threads; ///< Map of threads managed by the utilities class. + + + }; + +} + +#endif From 2aea3644e6a94bf1f35e2b77f86611812d16bbb3 Mon Sep 17 00:00:00 2001 From: brichards Date: Wed, 17 Jan 2024 16:44:12 +0000 Subject: [PATCH 05/18] updated makefile and seperated out temporary headers --- Makefile | 23 ++++++++++++++++------- tempinclude/README.md | 1 + 2 files changed, 17 insertions(+), 7 deletions(-) create mode 100644 tempinclude/README.md diff --git a/Makefile b/Makefile index b38435c..8f74fd6 100644 --- a/Makefile +++ b/Makefile @@ -14,28 +14,32 @@ TempToolsInclude = TempToolsLib = -Includes=-I $(SOURCEDIR)/include/ +Includes=-I $(SOURCEDIR)/include/ -I $(SOURCEDIR)/tempinclude/ Libs=-L $(SOURCEDIR)/lib/ -lStore -lLogging -lToolchain -lDataModelBase -lTempDataModel -lTempTools -lpthread LIBRARIES=lib/libStore.so lib/libLogging.so lib/libToolChain.so lib/libDataModelBase.so lib/libTempDataModel.so lib/libTempTools.so -HEADERS:=$(patsubst %.h, include/%.h, $(filter %.h, $(subst /, ,$(patsubst src/%.h, include/%.h, $(wildcard src/*/*.h) )))) -TempDataModelHEADERS:=$(patsubst %.h, include/%.h, $(filter %.h, $(subst /, ,$(patsubst src/%.h, include/%.h, $(wildcard DataModel/*.h))))) -MyToolHEADERS:=$(patsubst %.h, include/%.h, $(filter %.h, $(subst /, ,$(patsubst src/%.h, include/%.h, $(wildcard UserTools/*/*.h) $(wildcard UserTools/*.h))))) +HEADERS:=$(patsubst %.h, include/%.h, $(filter %.h, $(subst /, ,$(wildcard src/*/*.h) ))) include/Factory.h +TempDataModelHEADERS:=$(patsubst %.h, tempinclude/%.h, $(filter %.h, $(subst /, ,$(wildcard DataModel/*.h)))) +TempMyToolHEADERS:=$(patsubst %.h, tempinclude/%.h, $(filter %.h, $(subst /, ,$(wildcard UserTools/*/*.h) $(wildcard UserTools/*.h)))) SOURCEFILES:=$(patsubst %.cpp, %.o, $(wildcard */*.cpp) $(wildcard */*/*.cpp)) #.SECONDARY: $(%.o) -all: $(HEADERS) $(TempDataModelHEADERS) $(MyToolHEADERS) $(SOURCEFILES) $(LIBRARIES) main +all: $(HEADERS) $(TempDataModelHEADERS) $(TempMyToolHEADERS) $(SOURCEFILES) $(LIBRARIES) main debug: all -main: src/main.o $(LIBRARIES) $(HEADERS) $(TempDataModelHEADERS) $(MyToolHEADERS) | $(SOURCEFILES) +main: src/main.o $(LIBRARIES) $(HEADERS) $(TempDataModelHEADERS) $(TempMyToolHEADERS) | $(SOURCEFILES) @echo -e "\e[38;5;11m\n*************** Making " $@ " ****************\e[0m" g++ $(CXXFLAGS) $< -o $@ $(Includes) $(Libs) $(TempDataModelInclude) $(TempDataModellib) $(TempToolsInclude) $(TempToolslib) include/%.h: @echo -e "\e[38;5;87m\n*************** sym linking headers ****************\e[0m" - ln -s `pwd`/$(filter %$(strip $(patsubst include/%.h, /%.h, $@)), $(wildcard src/*/*.h) $(wildcard DataModel/*.h) $(wildcard UserTools/*/*.h) $(wildcard UserTools/*.h)) $@ + ln -s `pwd`/$(filter %$(strip $(patsubst include/%.h, /%.h, $@)), $(wildcard src/*/*.h) $(wildcard UserTools/*/*.h)) $@ + +tempinclude/%.h: + @echo -e "\e[38;5;87m\n*************** sym linking headers ****************\e[0m" + ln -s `pwd`/$(filter %$(strip $(patsubst tempinclude/%.h, /%.h, $@)), $(wildcard DataModel/*.h) $(wildcard UserTools/*/*.h) $(wildcard UserTools/*.h)) $@ src/%.o : src/%.cpp $(HEADERS) @echo -e "\e[38;5;214m\n*************** Making " $@ "****************\e[0m" @@ -82,6 +86,7 @@ clean: rm -f */*/*.o rm -f */*.o rm -f include/*.h + rm -f tempinclude/*.h rm -f lib/*.so Docs: @@ -92,3 +97,7 @@ test: $(patsubst %.cpp, %.o, $(wildcard */*.cpp) $(wildcard */*/*.cpp)) echo echo $(patsubst %.cpp, %.o, $(wildcard */*.cpp) $(wildcard */*/*.cpp)) # echo $(patsubst %, lib/Lib%.so, $(filter-out %.o %.cpp src, $(subst /, , $(wildcard src/*)))) + +test2: + echo $(patsubst %.h, include/%.h, $(filter %.h, $(subst /, ,$(wildcard src/*/*.h) ))) + echo $(patsubst %.h, include/%.h, $(filter %.h, $(subst /, ,$(patsubst src/%.h, include/%.h, $(wildcard src/*/*.h) )))) diff --git a/tempinclude/README.md b/tempinclude/README.md new file mode 100644 index 0000000..28e8dfa --- /dev/null +++ b/tempinclude/README.md @@ -0,0 +1 @@ +# DAQFramework From b9b1e8ecf7e722aff21f9f6ab5bd70f53b268009 Mon Sep 17 00:00:00 2001 From: brichards Date: Wed, 17 Jan 2024 18:00:52 +0000 Subject: [PATCH 06/18] changed source directory path --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 8f74fd6..ad884a3 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -SOURCEDIR=/host/Dependencies/ToolFrameworkCore +SOURCEDIR=`pwd` CXXFLAGS= -fPIC -O3 -Wpedantic -Wall -std=c++11 -Wno-comment -Wno-unused -Wextra -Wcast-align -Wcast-qual -Wctor-dtor-privacy -Wdisabled-optimization -Wformat=2 -Winit-self -Wlogical-op -Wmissing-declarations -Wmissing-include-dirs -Wnoexcept -Woverloaded-virtual -Wredundant-decls -Wshadow -Wsign-conversion -Wsign-promo -Wstrict-null-sentinel -Wstrict-overflow=5 -Wswitch-default -Wundef #-Werror -Wold-style-cast From a72de41b6a1dd80efb28382ccf8a020000cc696d Mon Sep 17 00:00:00 2001 From: brichards Date: Fri, 19 Jan 2024 11:54:17 +0000 Subject: [PATCH 07/18] updated application files for new v.3.0 --- Application/Setup.sh | 2 +- Makefile | 6 +++++- {UserTools => src}/Factory/Factory.h | 0 3 files changed, 6 insertions(+), 2 deletions(-) rename {UserTools => src}/Factory/Factory.h (100%) diff --git a/Application/Setup.sh b/Application/Setup.sh index bd87c85..916b6c9 100755 --- a/Application/Setup.sh +++ b/Application/Setup.sh @@ -4,6 +4,6 @@ Dependencies=`pwd`/Dependencies -export LD_LIBRARY_PATH=`pwd`/lib:$LD_LIBRARY_PATH +export LD_LIBRARY_PATH=`pwd`/lib:$Dependencies/ToolFrameworkCore/lib:$LD_LIBRARY_PATH export SEGFAULT_SIGNALS="all" diff --git a/Makefile b/Makefile index ad884a3..f3807b8 100644 --- a/Makefile +++ b/Makefile @@ -17,7 +17,7 @@ TempToolsLib = Includes=-I $(SOURCEDIR)/include/ -I $(SOURCEDIR)/tempinclude/ Libs=-L $(SOURCEDIR)/lib/ -lStore -lLogging -lToolchain -lDataModelBase -lTempDataModel -lTempTools -lpthread LIBRARIES=lib/libStore.so lib/libLogging.so lib/libToolChain.so lib/libDataModelBase.so lib/libTempDataModel.so lib/libTempTools.so -HEADERS:=$(patsubst %.h, include/%.h, $(filter %.h, $(subst /, ,$(wildcard src/*/*.h) ))) include/Factory.h +HEADERS:=$(patsubst %.h, include/%.h, $(filter %.h, $(subst /, ,$(wildcard src/*/*.h) ))) TempDataModelHEADERS:=$(patsubst %.h, tempinclude/%.h, $(filter %.h, $(subst /, ,$(wildcard DataModel/*.h)))) TempMyToolHEADERS:=$(patsubst %.h, tempinclude/%.h, $(filter %.h, $(subst /, ,$(wildcard UserTools/*/*.h) $(wildcard UserTools/*.h)))) SOURCEFILES:=$(patsubst %.cpp, %.o, $(wildcard */*.cpp) $(wildcard */*/*.cpp)) @@ -49,6 +49,10 @@ UnitTests/%.o : UnitTests/%.cpp $(HEADERS) @echo -e "\e[38;5;214m\n*************** Making " $@ "****************\e[0m" g++ $(CXXFLAGS) -c $< -o $@ $(Includes) +UserTools/Factory/Factory.o : UserTools/Factory/Factory.cpp $(HEADERS) $(TempDataModelHEADERS) + @echo -e "\e[38;5;214m\n*************** Making " $@ "****************\e[0m" + g++ $(CXXFLAGS) -c $< -o $@ $(Includes) $(TempDataModelInclude) $(TempToolsInclude) + UserTools/%.o : UserTools/%.cpp $(HEADERS) $(TempDataModelHEADERS) UserTools/%.h @echo -e "\e[38;5;214m\n*************** Making " $@ "****************\e[0m" g++ $(CXXFLAGS) -c $< -o $@ $(Includes) $(TempDataModelInclude) $(TempToolsInclude) diff --git a/UserTools/Factory/Factory.h b/src/Factory/Factory.h similarity index 100% rename from UserTools/Factory/Factory.h rename to src/Factory/Factory.h From 8347803fdead5dfc17fd4429c7f06685f139763f Mon Sep 17 00:00:00 2001 From: brichards Date: Fri, 26 Jan 2024 13:02:08 +0000 Subject: [PATCH 08/18] corrected make file typo --- Makefile | 2 +- src/ToolChain/ToolChain.cpp | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index f3807b8..a71f223 100644 --- a/Makefile +++ b/Makefile @@ -15,7 +15,7 @@ TempToolsLib = Includes=-I $(SOURCEDIR)/include/ -I $(SOURCEDIR)/tempinclude/ -Libs=-L $(SOURCEDIR)/lib/ -lStore -lLogging -lToolchain -lDataModelBase -lTempDataModel -lTempTools -lpthread +Libs=-L $(SOURCEDIR)/lib/ -lStore -lLogging -lToolChain -lDataModelBase -lTempDataModel -lTempTools -lpthread LIBRARIES=lib/libStore.so lib/libLogging.so lib/libToolChain.so lib/libDataModelBase.so lib/libTempDataModel.so lib/libTempTools.so HEADERS:=$(patsubst %.h, include/%.h, $(filter %.h, $(subst /, ,$(wildcard src/*/*.h) ))) TempDataModelHEADERS:=$(patsubst %.h, tempinclude/%.h, $(filter %.h, $(subst /, ,$(wildcard DataModel/*.h)))) diff --git a/src/ToolChain/ToolChain.cpp b/src/ToolChain/ToolChain.cpp index 1e47122..a85ee27 100644 --- a/src/ToolChain/ToolChain.cpp +++ b/src/ToolChain/ToolChain.cpp @@ -66,10 +66,10 @@ ToolChain::ToolChain(int verbose, int errorlevel, bool log_interactive, bool log m_log_split_files=log_split_files; m_log_local_path=log_local_path; - if(in_data_model==0) m_data=new DataModelBase; - else m_data=reinterpret_cast(in_data_model); + if(in_data_model==0) m_data=new DataModelBase; + else m_data=reinterpret_cast(in_data_model); // need to set a flag that you dont own the data model for sue during deletion. (check this for other constructor roo. - Init(); + Init(); //need to check if loging already made incase passing a datamodel for subtoolcahin } From 5e70f5f29fb1ab9be1541882aafd06eb72f7fc6d Mon Sep 17 00:00:00 2001 From: brichards Date: Fri, 26 Jan 2024 13:06:58 +0000 Subject: [PATCH 09/18] added makefile for applicaion --- Application/Makefile.new | 74 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 Application/Makefile.new diff --git a/Application/Makefile.new b/Application/Makefile.new new file mode 100644 index 0000000..5138a39 --- /dev/null +++ b/Application/Makefile.new @@ -0,0 +1,74 @@ +Dependencies=Dependencies +ToolFrameworkCore=$(Dependencies)/ToolFrameworkCore +SOURCEDIR=`pwd` + +CXXFLAGS= -fPIC -O3 -Wpedantic -Wall -std=c++11 -Wno-comment -Wno-unused -Wextra -Wcast-align -Wcast-qual -Wctor-dtor-privacy -Wdisabled-optimization -Wformat=2 -Winit-self -Wlogical-op -Wmissing-declarations -Wmissing-include-dirs -Wnoexcept -Woverloaded-virtual -Wredundant-decls -Wshadow -Wsign-conversion -Wsign-promo -Wstrict-null-sentinel -Wstrict-overflow=5 -Wswitch-default -Wundef #-Werror -Wold-style-cast + + +ifeq ($(MAKECMDGOALS),debug) +CXXFLAGS+= -O0 -g -lSegFault -rdynamic -DDEBUG +endif + +DataModelInclude = +DataModelLib = + +MyToolsInclude = +MyToolsLib = + + +Includes=-I $(ToolFrameworkCore)/include/ -I $(SOURCEDIR)/include/ +Libs=-L $(SOURCEDIR)/lib/ -lMyTools -lDataModel -L $(ToolFrameworkCore)/lib/ -lStore -lLogging -lToolChain -lDataModelBase -lpthread +LIBRARIES=lib/libDataModel.so lib/libMyTools.so +DataModelHEADERS:=$(patsubst %.h, include/%.h, $(filter %.h, $(subst /, ,$(wildcard DataModel/*.h)))) +MyToolHEADERS:=$(patsubst %.h, include/%.h, $(filter %.h, $(subst /, ,$(wildcard UserTools/*/*.h) $(wildcard UserTools/*.h)))) +SOURCEFILES:=$(patsubst %.cpp, %.o, $(wildcard */*.cpp) $(wildcard */*/*.cpp)) + +#.SECONDARY: $(%.o) + + +all: $(DataModelHEADERS) $(MyToolHEADERS) $(SOURCEFILES) $(LIBRARIES) main + +debug: all + +main: src/main.o $(LIBRARIES) $(DataModelHEADERS) $(MyToolHEADERS) | $(SOURCEFILES) + @echo -e "\e[38;5;11m\n*************** Making " $@ " ****************\e[0m" + g++ $(CXXFLAGS) $< -o $@ $(Includes) $(Libs) $(DataModelInclude) $(DataModellib) $(MyToolsInclude) $(MyToolslib) + +include/%.h: + @echo -e "\e[38;5;87m\n*************** sym linking headers ****************\e[0m" + ln -s `pwd`/$(filter %$(strip $(patsubst include/%.h, /%.h, $@)), $(wildcard DataModel/*.h) $(wildcard UserTools/*/*.h) $(wildcard UserTools/*.h)) $@ + +src/%.o : src/%.cpp + @echo -e "\e[38;5;214m\n*************** Making " $@ "****************\e[0m" + g++ $(CXXFLAGS) -c $< -o $@ $(Includes) + +UserTools/Factory/Factory.o : UserTools/Factory/Factory.cpp $(DataModelHEADERS) + @echo -e "\e[38;5;214m\n*************** Making " $@ "****************\e[0m" + g++ $(CXXFLAGS) -c $< -o $@ $(Includes) $(DataModelInclude) $(ToolsInclude) + +UserTools/%.o : UserTools/%.cpp $(DataModelHEADERS) UserTools/%.h + @echo -e "\e[38;5;214m\n*************** Making " $@ "****************\e[0m" + g++ $(CXXFLAGS) -c $< -o $@ $(Includes) $(DataModelInclude) $(ToolsInclude) + +DataModel/%.o : DataModel/%.cpp DataModel/%.h $(DataModelHEADERS) + @echo -e "\e[38;5;214m\n*************** Making " $@ "****************\e[0m" + g++ $(CXXFLAGS) -c $< -o $@ $(Includes) $(DataModelInclude) + +lib/libDataModel.so: $(patsubst %.cpp, %.o , $(wildcard DataModel/*.cpp)) | $(DataModelInclude) + @echo -e "\e[38;5;201m\n*************** Making " $@ "****************\e[0m" + g++ $(CXXFLAGS) --shared $^ -o $@ $(Includes) $(DataModelInclude) + +lib/libMyTools.so: $(patsubst %.cpp, %.o , $(wildcard UserTools/*/*.cpp)) | $(DataModelInclude) $(MyToolsInclude) + @echo -e "\e[38;5;201m\n*************** Making " $@ "****************\e[0m" + g++ $(CXXFLAGS) --shared $^ -o $@ $(Includes) $(DataModelInclude) $(MyToolsInclude) + +clean: + @echo -e "\e[38;5;201m\n*************** Cleaning up ****************\e[0m" + rm -f */*/*.o + rm -f */*.o + rm -f include/*.h + rm -f lib/*.so + +Docs: + doxygen Doxyfile + From 9694b1680d1aef02c705607f2dab47c6b3c744c1 Mon Sep 17 00:00:00 2001 From: brichards Date: Fri, 26 Jan 2024 14:56:12 +0000 Subject: [PATCH 10/18] updated makefile dependancy typo --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index a71f223..4bb50a3 100644 --- a/Makefile +++ b/Makefile @@ -77,11 +77,11 @@ lib/libToolChain.so: $(patsubst %.cpp, %.o , $(wildcard src/ToolChain/*.cpp)) | @echo -e "\e[38;5;201m\n*************** Making " $@ "****************\e[0m" g++ $(CXXFLAGS) --shared $^ -o $@ $(Includes) -lib/libTempDataModel.so: $(patsubst %.cpp, %.o , $(wildcard DataModel/*.cpp)) | $(HEADERS) $(TempDataModelInclude) +lib/libTempDataModel.so: $(patsubst %.cpp, %.o , $(wildcard DataModel/*.cpp)) | $(HEADERS) $(TempDataModelHEADERS) @echo -e "\e[38;5;201m\n*************** Making " $@ "****************\e[0m" g++ $(CXXFLAGS) --shared $^ -o $@ $(Includes) $(TempDataModelInclude) -lib/libTempTools.so: $(patsubst %.cpp, %.o , $(wildcard UserTools/*/*.cpp)) | $(HEADERS) $(TempDataModelInclude) $(TempToolsInclude) +lib/libTempTools.so: $(patsubst %.cpp, %.o , $(wildcard UserTools/*/*.cpp)) | $(HEADERS) $(TempDataModelHEADERS) $(TempMyToolHEADERS) @echo -e "\e[38;5;201m\n*************** Making " $@ "****************\e[0m" g++ $(CXXFLAGS) --shared $^ -o $@ $(Includes) $(TempDataModelInclude) $(TempToolsInclude) From 999c7ae0b7bcb9e703b42ae13bbf188dbf9904aa Mon Sep 17 00:00:00 2001 From: brichards Date: Fri, 26 Jan 2024 16:38:42 +0000 Subject: [PATCH 11/18] changed coulours to be consts not defined and also use terminal basic pallet --- src/Logging/Logging.h | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/src/Logging/Logging.h b/src/Logging/Logging.h index fe45a5f..c0789fc 100644 --- a/src/Logging/Logging.h +++ b/src/Logging/Logging.h @@ -13,25 +13,25 @@ namespace ToolFramework{ -#define red "\033[38;5;196m" -#define darkred "\033[38;5;88m" -#define green "\033[38;5;46m" -#define darkgreen "\033[38;5;22m" -#define blue "\033[38;5;21m" -#define darkblue "\033[38;5;18m" -#define yellow "\033[38;5;226m" -#define darkyellow "\033[38;5;142m" -#define orange "\033[38;5;208m" -#define darkorange "\033[38;5;130m" -#define pink "\033[38;5;201m" -#define darkpink "\033[38;5;129m" -#define purple "\033[38;5;57m" -#define darkpurple "\033[38;5;54m" -#define cyan "\033[38;5;51m" -#define darkcyan "\033[38;5;39m" -#define white "\033[38;5;255m" -#define gray "\033[38;5;243m" -#define plain "\033[0m" + const char red[] = "\033[31m"; //"\033[38;5;88m" + const char lightred[] = "\033[91m"; //"\033[38;5;196m" + const char green[] = "\033[32m"; //"\033[38;5;22m" + const char lightgreen[] = "\033[92m"; //"\033[38;5;46m" + const char blue[] = "\033[34m"; //"\033[38;5;18m" + const char lightblue[] = "\033[94m"; //"\033[38;5;21m" + const char yellow[] = "\033[33m"; //"\033[38;5;142m" + const char lightyellow[] = "\033[93m"; //"\033[38;5;226m" + const char orange[] = "\033[38;5;130m"; + const char lightorange[] = "\033[38;5;208m"; + const char pink[] = "\033[35m"; //"\033[38;5;129m" + const char lightpink[] = "\033[95m"; //"\033[38;5;201m" + const char purple[] = "\033[38;5;54m"; + const char lightpurple[] = "\033[38;5;57m"; + const char cyan[] = "\033[36m"; //"\033[38;5;39m" + const char lightcyan[] = "\033[96m"; //"\033[38;5;51m" + const char white[] = "\033[97m"; //"\033[38;5;255m" + const char gray[] = "\033[37m"; //"\033[38;5;243m" + const char plain[] ="\033[39m"; //"\033[0m" /** * \struct MsgL From dfea4a7440f0ad63660df8d783341a6661b0a579 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 19 Mar 2024 07:30:14 +0000 Subject: [PATCH 12/18] added no colour option in make and made log function thread safe and Tool log function print tool name --- Makefile | 8 ++- src/Logging/Logging.cpp | 6 ++- src/Logging/Logging.h | 110 ++++++++++++++++++++++++++++++++-------- src/Tool/Tool.h | 6 +-- 4 files changed, 103 insertions(+), 27 deletions(-) diff --git a/Makefile b/Makefile index 4bb50a3..ddf6e37 100644 --- a/Makefile +++ b/Makefile @@ -1,12 +1,16 @@ SOURCEDIR=`pwd` -CXXFLAGS= -fPIC -O3 -Wpedantic -Wall -std=c++11 -Wno-comment -Wno-unused -Wextra -Wcast-align -Wcast-qual -Wctor-dtor-privacy -Wdisabled-optimization -Wformat=2 -Winit-self -Wlogical-op -Wmissing-declarations -Wmissing-include-dirs -Wnoexcept -Woverloaded-virtual -Wredundant-decls -Wshadow -Wsign-conversion -Wsign-promo -Wstrict-null-sentinel -Wstrict-overflow=5 -Wswitch-default -Wundef #-Werror -Wold-style-cast +CXXFLAGS= -fPIC -O3 -Wpedantic -Wall -std=c++11 -Wno-comment -Wno-unused -Wextra -Wcast-align -Wcast-qual -Wctor-dtor-privacy -Wdisabled-optimization -Wformat=2 -Winit-self -Wlogical-op -Wmissing-declarations -Wmissing-include-dirs -Wnoexcept -Woverloaded-virtual -Wredundant-decls -Wshadow -Wsign-conversion -Wsign-promo -Wstrict-null-sentinel -Wstrict-overflow=5 -Wswitch-default -Wundef #-Werror -Wold-style-cast ifeq ($(MAKECMDGOALS),debug) CXXFLAGS+= -O0 -g -lSegFault -rdynamic -DDEBUG endif +ifeq ($(MAKECMDGOALS),no_colour) +CXXFLAGS+= -DNO_COLOUR +endif + TempDataModelInclude = TempDataModelLib = @@ -27,6 +31,8 @@ SOURCEFILES:=$(patsubst %.cpp, %.o, $(wildcard */*.cpp) $(wildcard */*/*.cpp)) all: $(HEADERS) $(TempDataModelHEADERS) $(TempMyToolHEADERS) $(SOURCEFILES) $(LIBRARIES) main + +no_colour: all debug: all main: src/main.o $(LIBRARIES) $(HEADERS) $(TempDataModelHEADERS) $(TempMyToolHEADERS) | $(SOURCEFILES) diff --git a/src/Logging/Logging.cpp b/src/Logging/Logging.cpp index 7f7e74f..e979656 100644 --- a/src/Logging/Logging.cpp +++ b/src/Logging/Logging.cpp @@ -37,6 +37,7 @@ Logging::TFStreamBuf::TFStreamBuf ( bool interactive, bool local, std::string lo m_interactive=interactive; m_error=error; + if(m_error){ m_messagelevel=0; m_verbose=0; @@ -79,7 +80,6 @@ Logging::TFStreamBuf::TFStreamBuf ( bool interactive, bool local, std::string lo int Logging::TFStreamBuf::sync ( ) { - if( (( m_interactive || m_local) && (m_messagelevel <= m_verbose)) && str()!=""){ time_t rawtime; @@ -122,12 +122,14 @@ int Logging::TFStreamBuf::sync ( ) (*output)<<"["; if(m_error) (*output)<<"ERROR"; else (*output)<flush(); } } str(""); + + return 0; } diff --git a/src/Logging/Logging.h b/src/Logging/Logging.h index c0789fc..f290db0 100644 --- a/src/Logging/Logging.h +++ b/src/Logging/Logging.h @@ -10,9 +10,12 @@ #include #include +#include +#include namespace ToolFramework{ - + + #ifndef NO_COLOUR const char red[] = "\033[31m"; //"\033[38;5;88m" const char lightred[] = "\033[91m"; //"\033[38;5;196m" const char green[] = "\033[32m"; //"\033[38;5;22m" @@ -33,6 +36,31 @@ namespace ToolFramework{ const char gray[] = "\033[37m"; //"\033[38;5;243m" const char plain[] ="\033[39m"; //"\033[0m" + #else + + const char red[] = ""; + const char lightred[] = ""; + const char green[] = ""; + const char lightgreen[] = ""; + const char blue[] = ""; + const char lightblue[] = ""; + const char yellow[] = ""; + const char lightyellow[] = ""; + const char orange[] = ""; + const char lightorange[] = ""; + const char pink[] = ""; + const char lightpink[] = ""; + const char purple[] = ""; + const char lightpurple[] = ""; + const char cyan[] = ""; + const char lightcyan[] = ""; + const char white[] = ""; + const char gray[] = ""; + const char plain[] = ""; + +#endif + + /** * \struct MsgL * @@ -95,7 +123,10 @@ namespace ToolFramework{ std::ostream* output; std::ostream* fileoutput; - + + std::mutex lock1; + std::mutex lock2; + protected: std::ostream* tmp; @@ -108,6 +139,7 @@ namespace ToolFramework{ std::streambuf *psbuf, *backup1, *backup2; bool no_delete; + }; @@ -142,26 +174,35 @@ namespace ToolFramework{ */ - template void Log(T message, int messagelevel=1, int verbose=1){ - - - if(messagelevel<=verbose){ - int previous_messagelevel = buffer->m_messagelevel; - int previous_verbosity = buffer->m_verbose; - - buffer->m_messagelevel=messagelevel; - buffer->m_verbose=verbose; - - std::cout.rdbuf(buffer); - std::cout< void Log(T message, int messagelevel=1, int verbose=1){ + //printf("logmessage\n"); + if(messagelevel<=verbose){ + + buffer->lock1.lock(); + while(!buffer->lock2.try_lock()){ + buffer->lock1.unlock(); + usleep(100); + buffer->lock1.lock(); + } + //printf("locg message locked\n"); + int previous_messagelevel = buffer->m_messagelevel; + int previous_verbosity = buffer->m_verbose; + + buffer->m_messagelevel=messagelevel; + buffer->m_verbose=verbose; + //printf("log about to sync\n"); + std::cout.rdbuf(buffer); + std::cout<m_messagelevel=previous_messagelevel; + buffer->m_verbose=previous_verbosity; + buffer->lock2.unlock(); + buffer->lock1.unlock(); + } - buffer->m_messagelevel=previous_messagelevel; - buffer->m_verbose=previous_verbosity; - } + } + - } - - /** Functionn to change the logs out file if set to a local path. @@ -175,36 +216,63 @@ namespace ToolFramework{ Logging& operator<<(MsgL a){ + + buffer->lock1.lock(); + buffer->lock2.try_lock(); buffer->m_messagelevel=a.messagelevel; buffer->m_verbose=a.verbose; + buffer->lock2.unlock(); + buffer->lock1.unlock(); + return *this; } - Logging& operator<<(std::ostream& (*foo)(std::ostream&)) { + Logging& operator<<(std::ostream& (*foo)(std::ostream&)) { + //printf("special stream tying to lock\n"); + buffer->lock1.lock(); + buffer->lock2.try_lock(); + + //printf("special stream unlocking and about to sync\n"); std::cout.rdbuf(buffer); std::cout<lock2.unlock(); + buffer->lock1.unlock(); return *this; } template Logging& operator<<(T &a){ + //printf("stream locking\n"); + buffer->lock1.lock(); + buffer->lock2.try_lock(); + //printf("stream locked\n"); std::cout.rdbuf(buffer); std::cout<lock1.unlock(); + //printf("stream unlocked\n"); return *this; } template Logging& operator<<(const T &a){ + //printf("stream locking\n"); + buffer->lock1.lock(); + buffer->lock2.try_lock(); + //printf("stream locked\n"); std::cout.rdbuf(buffer); std::cout<lock1.unlock(); + //printf("stream unlocked\n"); + return *this; } diff --git a/src/Tool/Tool.h b/src/Tool/Tool.h index 1c3a925..984d141 100644 --- a/src/Tool/Tool.h +++ b/src/Tool/Tool.h @@ -29,7 +29,7 @@ namespace ToolFramework{ virtual bool Execute()=0; ///< Virtual Execute function. virtual bool Finalise()=0; ///< Virtual Finalise function. virtual ~Tool(){}; ///< virtual destructor. - std::string Getname() {return m_tool_name;}; + std::string GetName() {return m_tool_name;}; void SetName(std::string name) {m_tool_name=name;}; protected: @@ -41,8 +41,8 @@ namespace ToolFramework{ int m_verbose; ///< verbosity variable for direct logging level MsgL ML(int messagelevel) {return MsgL(messagelevel,m_verbose);} ///< Function for setting logging level instream @param messagelevel the verboisty level at which to show the message. Checked against internal verbosity level. void MLC() {*(m_log)< void Log(T message, int messagelevel, int verbosity){m_log->Log(message,messagelevel,verbosity);} - template void Log(T message, int messagelevel=0){m_log->Log(message,messagelevel,m_verbose);} ///< Logging fuction for printouts. @param message Templated message string. @param messagelevel The verbosity level at which to show the message. Checked against internal verbosity level + template void Log(T message, int messagelevel, int verbosity){m_log->Log("-"+GetName()+"-: "+message,messagelevel,verbosity);} + template void Log(T message, int messagelevel=0){m_log->Log("-"+GetName()+"-: "+message,messagelevel,m_verbose);} ///< Logging fuction for printouts. @param message Templated message string. @param messagelevel The verbosity level at which to show the message. Checked against internal verbosity level private: From ab3a29d66b1414e1ce755764e3ce1971f0b6d155 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 20 Mar 2024 05:54:28 +0000 Subject: [PATCH 13/18] added thread safety and toolname information to dummy tool printouts --- UserTools/DummyTool/DummyTool.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/UserTools/DummyTool/DummyTool.cpp b/UserTools/DummyTool/DummyTool.cpp index 6385a62..9d41a7b 100644 --- a/UserTools/DummyTool/DummyTool.cpp +++ b/UserTools/DummyTool/DummyTool.cpp @@ -26,8 +26,13 @@ bool DummyTool::Execute(){ // Therefore a message level of 0 is always printed so should be used for high priority messages e.g. errors // and a message level or 9 would be for minor messgaes rarely printed - Log("test 2a"); // defualt log function message level is 0 - *m_log<<"test 2b"< Date: Tue, 26 Mar 2024 01:00:27 +0000 Subject: [PATCH 14/18] updated Makefile and cmake files and changed implied binary int conversion --- Application/CMakeLists.txt | 25 +++++++-------- Application/Makefile.new | 18 +++++++---- CMakeLists.txt | 13 +++++--- UnitTests/StoreTest.cpp | 28 ++++++++--------- src/Store/BinaryStream.h | 64 +++++++++++++++++++------------------- 5 files changed, 78 insertions(+), 70 deletions(-) diff --git a/Application/CMakeLists.txt b/Application/CMakeLists.txt index 17ce6d1..f16be6a 100644 --- a/Application/CMakeLists.txt +++ b/Application/CMakeLists.txt @@ -1,3 +1,5 @@ +#todo sym links not copy headers, use macro to seach for .so files in Usertools and add the libraries to libs list and symlink to libs folder + cmake_minimum_required (VERSION 2.6) project (ToolFrameworkApplicaiton) @@ -10,11 +12,15 @@ set(MYTOOLS_INC "") set(MYTOOLS_LIB_PATH "") set(MYTOOLS_LIBS "") -include_directories (${DATAMODEL_INC} ${MYTOOLS_INC}) -link_directories(${DATAMODEL_LIB_PATH} ${MYTOOLS_LIB_PATH}) +set(TOOLFRAMEWORK_INC "${PROJECT_SOURCE_DIR}/Dependencies/ToolFrameworkCore/include") +set(TOOLFRAMEWORK_LIBS_PATH "${PROJECT_SOURCE_DIR}/Dependencies/ToolFrameworkCore/lib") +set(TOOLFRAMEWORK_LIBS "-lDataModelBase -lLogging -lStore -lToolChain") + +include_directories (${DATAMODEL_INC} ${MYTOOLS_INC} ${TOOLFRAMEWORK_INC}) +link_directories(${DATAMODEL_LIB_PATH} ${MYTOOLS_LIB_PATH} ${TOOLFRAMEWORK_LIBS_PATH}) MACRO(HEADER_DIRECTORIES return_list) - FILE(GLOB_RECURSE new_list ${PROJECT_SOURCE_DIR}/*.h) + FILE(GLOB_RECURSE new_list ${PROJECT_SOURCE_DIR}/src/*.h ${PROJECT_SOURCE_DIR}/DataModel/*.h ${PROJECT_SOURCE_DIR}/UserTools/*.h ) FILE(COPY ${new_list} DESTINATION ${PROJECT_BINARY_DIR}/include) SET(dir_list "") FOREACH(file_path ${new_list}) @@ -30,13 +36,9 @@ FILE(COPY ${PROJECT_SOURCE_DIR}/configfiles DESTINATION ${PROJECT_BINARY_DIR}/) HEADER_DIRECTORIES(header_list) include_directories(${header_list}) -set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib) - -file(GLOB_RECURSE STORE_SRC RELATIVE ${CMAKE_SOURCE_DIR} "Dependencies/ToolFrameworkCore/src/Store/*.cpp") -add_library(Store SHARED ${STORE_SRC}) +message(header_list=${header_list}) -file(GLOB_RECURSE LOGGING_SRC RELATIVE ${CMAKE_SOURCE_DIR} "Dependencies/ToolFrameworkCore/src/Logging/*.cpp") -add_library(Logging SHARED ${LOGGING_SRC}) +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib) file(GLOB_RECURSE DATAMODEL_SRC RELATIVE ${CMAKE_SOURCE_DIR} "DataModel/*.cpp") add_library(DataModel SHARED ${DATAMODEL_SRC}) @@ -44,8 +46,5 @@ add_library(DataModel SHARED ${DATAMODEL_SRC}) file(GLOB_RECURSE MYTOOLS_SRC RELATIVE ${CMAKE_SOURCE_DIR} "UserTools/*.cpp") add_library(MyTools SHARED ${MYTOOLS_SRC}) -file(GLOB_RECURSE TOOLCHAIN_SRC RELATIVE ${CMAKE_SOURCE_DIR} "Dependencies/ToolFrameworkCore/src/ToolChain/*.cpp") -add_library(ToolChain SHARED ${TOOLCHAIN_SRC}) - add_executable (main ${PROJECT_SOURCE_DIR}/src/main.cpp) -target_link_libraries (main Store Logging ToolChain MyTools DataModel pthread ${DATAMODEL_LIBS} ${MYTOOLS_LIBS}) +target_link_libraries (main MyTools DataModel pthread ${DATAMODEL_LIBS} ${MYTOOLS_LIBS} ${TOOLFRAMEWORK_LIBS}) diff --git a/Application/Makefile.new b/Application/Makefile.new index 5138a39..a25855f 100644 --- a/Application/Makefile.new +++ b/Application/Makefile.new @@ -15,16 +15,18 @@ DataModelLib = MyToolsInclude = MyToolsLib = - Includes=-I $(ToolFrameworkCore)/include/ -I $(SOURCEDIR)/include/ -Libs=-L $(SOURCEDIR)/lib/ -lMyTools -lDataModel -L $(ToolFrameworkCore)/lib/ -lStore -lLogging -lToolChain -lDataModelBase -lpthread -LIBRARIES=lib/libDataModel.so lib/libMyTools.so +ToolLibraries = $(patsubst %, lib/%, $(filter lib%, $(subst /, , $(wildcard UserTools/*/*.so)))) +LIBRARIES=lib/libDataModel.so lib/libMyTools.so $(ToolLibraries) DataModelHEADERS:=$(patsubst %.h, include/%.h, $(filter %.h, $(subst /, ,$(wildcard DataModel/*.h)))) MyToolHEADERS:=$(patsubst %.h, include/%.h, $(filter %.h, $(subst /, ,$(wildcard UserTools/*/*.h) $(wildcard UserTools/*.h)))) -SOURCEFILES:=$(patsubst %.cpp, %.o, $(wildcard */*.cpp) $(wildcard */*/*.cpp)) +ToolLibs = $(patsubst %.so, %, $(patsubst lib%, -l%,$(filter lib%, $(subst /, , $(wildcard UserTools/*/*.so))))) +AlreadyCompiled = $(wildcard UserTools/$(filter-out %.so UserTools , $(subst /, ,$(wildcard UserTools/*/*.so)))/*.cpp) +SOURCEFILES:=$(patsubst %.cpp, %.o, $(filter-out $(AlreadyCompiled), $(wildcard */*.cpp) $(wildcard */*/*.cpp))) +Libs=-L $(SOURCEDIR)/lib/ -lMyTools -lDataModel -L $(ToolFrameworkCore)/lib/ -lStore -lLogging -lToolChain -lDataModelBase -lpthread $(ToolLibs) -#.SECONDARY: $(%.o) +#.SECONDARY: $(%.o) all: $(DataModelHEADERS) $(MyToolHEADERS) $(SOURCEFILES) $(LIBRARIES) main @@ -58,10 +60,14 @@ lib/libDataModel.so: $(patsubst %.cpp, %.o , $(wildcard DataModel/*.cpp)) | $(D @echo -e "\e[38;5;201m\n*************** Making " $@ "****************\e[0m" g++ $(CXXFLAGS) --shared $^ -o $@ $(Includes) $(DataModelInclude) -lib/libMyTools.so: $(patsubst %.cpp, %.o , $(wildcard UserTools/*/*.cpp)) | $(DataModelInclude) $(MyToolsInclude) +lib/libMyTools.so: $(patsubst %.cpp, %.o , $(filter-out $(AlreadyCompiled), $(wildcard UserTools/*/*.cpp))) | $(DataModelInclude) $(MyToolsInclude) @echo -e "\e[38;5;201m\n*************** Making " $@ "****************\e[0m" g++ $(CXXFLAGS) --shared $^ -o $@ $(Includes) $(DataModelInclude) $(MyToolsInclude) +lib/%.so: + @echo -e "\e[38;5;87m\n*************** sym linking Tool libs ****************\e[0m" + ln -s `pwd`/$(filter %$(strip $(patsubst lib/%.so, /%.so ,$@)), $(wildcard UserTools/*/*.so)) $@ + clean: @echo -e "\e[38;5;201m\n*************** Cleaning up ****************\e[0m" rm -f */*/*.o diff --git a/CMakeLists.txt b/CMakeLists.txt index 534f1f0..abf7751 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -37,14 +37,17 @@ add_library(Store SHARED ${STORE_SRC}) file(GLOB_RECURSE LOGGING_SRC RELATIVE ${CMAKE_SOURCE_DIR} "src/Logging/*.cpp") add_library(Logging SHARED ${LOGGING_SRC}) -file(GLOB_RECURSE DATAMODEL_SRC RELATIVE ${CMAKE_SOURCE_DIR} "DataModel/*.cpp") -add_library(DataModel SHARED ${DATAMODEL_SRC}) +file(GLOB_RECURSE DATAMODELBASE_SRC RELATIVE ${CMAKE_SOURCE_DIR} "src/DataModelBase/*.cpp") +add_library(DataModelBase SHARED ${DATAMODELBASE_SRC}) -file(GLOB_RECURSE MYTOOLS_SRC RELATIVE ${CMAKE_SOURCE_DIR} "UserTools/*.cpp") -add_library(MyTools SHARED ${MYTOOLS_SRC}) +file(GLOB_RECURSE TEMPDATAMODEL_SRC RELATIVE ${CMAKE_SOURCE_DIR} "DataModel/*.cpp") +add_library(TempDataModel SHARED ${TEMPDATAMODEL_SRC}) + +file(GLOB_RECURSE TEMPTOOLS_SRC RELATIVE ${CMAKE_SOURCE_DIR} "UserTools/*.cpp") +add_library(TempTools SHARED ${TEMPTOOLS_SRC}) file(GLOB_RECURSE TOOLCHAIN_SRC RELATIVE ${CMAKE_SOURCE_DIR} "src/ToolChain/*.cpp") add_library(ToolChain SHARED ${TOOLCHAIN_SRC}) add_executable (main ${PROJECT_SOURCE_DIR}/src/main.cpp) -target_link_libraries (main Store Logging ToolChain MyTools DataModel pthread ${DATAMODEL_LIBS} ${MYTOOLS_LIBS}) +target_link_libraries (main Store Logging DataModelBase ToolChain TempTools TempDataModel pthread ${DATAMODEL_LIBS} ${MYTOOLS_LIBS}) diff --git a/UnitTests/StoreTest.cpp b/UnitTests/StoreTest.cpp index e1f1721..3fca299 100644 --- a/UnitTests/StoreTest.cpp +++ b/UnitTests/StoreTest.cpp @@ -67,20 +67,20 @@ float m2=0; bool n2=false; -pass*=store.Get("a",a2); -pass*=store.Get("b",b2); -pass*=store.Get("c",c2); -pass*=store.Get("d",d2); -pass*=store.Get("e",e2); -pass*=store.Get("f",f2); -pass*=store.Get("g",g2); -pass*=store.Get("h",h2); -pass*=store.Get("i",i2); -const int j2=store.Get("j"); -pass*=store.Get("k",k2); -pass*=store.Get("l",l2); -pass*=store.Get("m",m2); -pass*=store.Get("n",n2); + pass= pass && (store.Get("a",a2)); + pass= pass && (store.Get("b",b2)); + pass= pass && (store.Get("c",c2)); + pass= pass && (store.Get("d",d2)); + pass= pass && (store.Get("e",e2)); + pass= pass && (store.Get("f",f2)); + pass= pass && (store.Get("g",g2)); + pass= pass && (store.Get("h",h2)); + pass= pass && (store.Get("i",i2)); + const int j2=store.Get("j"); + pass= pass && (store.Get("k",k2)); + pass= pass && (store.Get("l",l2)); + pass= pass && (store.Get("m",m2)); + pass= pass && (store.Get("n",n2)); bool tmp=true; diff --git a/src/Store/BinaryStream.h b/src/Store/BinaryStream.h index b9dff6d..dadc156 100644 --- a/src/Store/BinaryStream.h +++ b/src/Store/BinaryStream.h @@ -63,8 +63,8 @@ namespace ToolFramework{ if(m_mode!=READ){ bool ret=true; unsigned int tmp=rhs.length(); - ret*=(*this) << tmp; - if(tmp) ret*=Bwrite(&(rhs[0]), tmp); + ret= ret && ((*this) << tmp); + if(tmp) ret= ret && (Bwrite(&(rhs[0]), tmp)); return ret; } else return false; @@ -74,9 +74,9 @@ namespace ToolFramework{ if(m_mode!=NEW && m_mode!=APPEND){ bool ret=true; unsigned int tmp=0; - ret*=(*this) >> tmp; + ret= ret && ((*this) >> tmp); rhs.resize(tmp); - if(tmp) ret*=Bread(&(rhs[0]), tmp); + if(tmp) ret= ret && (Bread(&(rhs[0]), tmp)); return ret; } else return false; @@ -91,8 +91,8 @@ namespace ToolFramework{ if(m_mode!=READ){ bool ret=true; unsigned int tmp=rhs.length(); - ret*=(*this) << tmp; - if(tmp) ret*=Bwrite(&(rhs[0]), tmp); + ret= ret && ((*this) << tmp); + if(tmp) ret= ret && (Bwrite(&(rhs[0]), tmp)); return ret; } else return false; @@ -158,12 +158,12 @@ namespace ToolFramework{ if(m_mode!=READ){ bool ret=true; unsigned int tmp=rhs.size(); - ret*=(*this) << tmp; + ret= ret && ((*this) << tmp); if(tmp){ if(check_base::value){ - for(typename std::vector::iterator it=rhs.begin(); it!=rhs.end(); it++) ret*=(*this) << (*it); + for(typename std::vector::iterator it=rhs.begin(); it!=rhs.end(); it++) ret= ret && ((*this) << (*it)); } - else ret*=Bwrite(&(rhs[0]), tmp*sizeof(T)); + else ret= ret && (Bwrite(&(rhs[0]), tmp*sizeof(T))); } return ret; } @@ -175,13 +175,13 @@ namespace ToolFramework{ if(m_mode!=NEW && m_mode!=APPEND){ bool ret=true; unsigned int tmp=0; - ret*=(*this) >> tmp; + ret= ret && ((*this) >> tmp); rhs.resize(tmp); if(tmp){ if(check_base::value){ - for(typename std::vector::iterator it=rhs.begin(); it!=rhs.end(); it++) ret*=(*this) >> (*it); + for(typename std::vector::iterator it=rhs.begin(); it!=rhs.end(); it++) ret= ret && ((*this) >> (*it)); } - else ret*=Bread(&(rhs[0]), tmp*sizeof(T)); + else ret= ret && (Bread(&(rhs[0]), tmp*sizeof(T))); } return ret; } @@ -198,9 +198,9 @@ namespace ToolFramework{ if(m_mode!=READ){ bool ret=true; unsigned int tmp=rhs.size(); - ret*=(*this) << tmp; + ret= ret && ((*this) << tmp); for(unsigned int i=0; i> tmp; + ret= ret && ((*this) >> tmp); rhs.resize(tmp); for(unsigned int i=0; i> rhs.at(i); + ret= ret && ((*this) >> rhs.at(i)); } return ret; } @@ -230,12 +230,12 @@ namespace ToolFramework{ if(m_mode!=READ){ bool ret=true; unsigned int tmp=rhs.size(); - ret*=(*this) << tmp; + ret= ret && ((*this) << tmp); for (typename std::map::iterator it=rhs.begin(); it!=rhs.end(); ++it){ T key=it->first; U value=it->second; - ret*=(*this) << key; - ret*=(*this) << value; + ret= ret && ((*this) << key); + ret= ret && ((*this) << value); } return ret; } @@ -246,12 +246,12 @@ namespace ToolFramework{ if(m_mode!=NEW && m_mode!=APPEND){ bool ret=true; unsigned int tmp=0; - ret*=(*this) >> tmp; + ret= ret && ((*this) >> tmp); for (unsigned int i=0; i> key; - ret*=(*this) >> value; + ret= ret && ((*this) >> key); + ret= ret && ((*this) >> value); rhs[key]=value; } return ret; @@ -268,12 +268,12 @@ namespace ToolFramework{ if(m_mode!=READ){ bool ret=true; unsigned int tmp=rhs.size(); - ret*=(*this) << tmp; + ret= ret && ((*this) << tmp); if(tmp){ if(check_base::value){ - for(typename std::deque::iterator it=rhs.begin(); it!=rhs.end(); it++) ret*=(*this) << (*it); + for(typename std::deque::iterator it=rhs.begin(); it!=rhs.end(); it++) ret= ret && ((*this) << (*it)); } - else ret*=Bwrite(&(rhs[0]), tmp*sizeof(T)); + else ret= ret && (Bwrite(&(rhs[0]), tmp*sizeof(T))); } return ret; } @@ -284,13 +284,13 @@ namespace ToolFramework{ if(m_mode!=NEW && m_mode!=APPEND){ bool ret=true; unsigned int tmp=0; - ret*=(*this) >> tmp; + ret= ret && ((*this) >> tmp); rhs.resize(tmp); if(tmp){ if(check_base::value){ - for(typename std::deque::iterator it=rhs.begin(); it!=rhs.end(); it++) ret*=(*this) >> (*it); + for(typename std::deque::iterator it=rhs.begin(); it!=rhs.end(); it++) ret= ret && ((*this) >> (*it)); } - else ret*=Bread(&(rhs[0]), tmp*sizeof(T)); + else ret= ret && (Bread(&(rhs[0]), tmp*sizeof(T))); } return ret; } @@ -306,9 +306,9 @@ namespace ToolFramework{ if(m_mode!=READ){ bool ret=true; unsigned int tmp=rhs.size(); - ret*=(*this) << tmp; + ret= ret && ((*this) << tmp); for(unsigned int i=0; i> tmp; + ret= ret && ((*this) >> tmp); rhs.resize(tmp); for(unsigned int i=0; i> rhs.at(i); + ret= ret && ((*this) >> rhs.at(i)); } return ret; } From 39cb6732b7ce56c6fb888b57ff8543a6a52a9490 Mon Sep 17 00:00:00 2001 From: brichards64 Date: Tue, 26 Mar 2024 01:12:11 +0000 Subject: [PATCH 15/18] updated makefile to execute pwd commands --- Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index ddf6e37..61d2972 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -SOURCEDIR=`pwd` +SOURCEDIR !=pwd CXXFLAGS= -fPIC -O3 -Wpedantic -Wall -std=c++11 -Wno-comment -Wno-unused -Wextra -Wcast-align -Wcast-qual -Wctor-dtor-privacy -Wdisabled-optimization -Wformat=2 -Winit-self -Wlogical-op -Wmissing-declarations -Wmissing-include-dirs -Wnoexcept -Woverloaded-virtual -Wredundant-decls -Wshadow -Wsign-conversion -Wsign-promo -Wstrict-null-sentinel -Wstrict-overflow=5 -Wswitch-default -Wundef #-Werror -Wold-style-cast @@ -41,11 +41,11 @@ main: src/main.o $(LIBRARIES) $(HEADERS) $(TempDataModelHEADERS) $(TempMyToolHEA include/%.h: @echo -e "\e[38;5;87m\n*************** sym linking headers ****************\e[0m" - ln -s `pwd`/$(filter %$(strip $(patsubst include/%.h, /%.h, $@)), $(wildcard src/*/*.h) $(wildcard UserTools/*/*.h)) $@ + ln -s $(SOURCEDIR)/$(filter %$(strip $(patsubst include/%.h, /%.h, $@)), $(wildcard src/*/*.h) $(wildcard UserTools/*/*.h)) $@ tempinclude/%.h: @echo -e "\e[38;5;87m\n*************** sym linking headers ****************\e[0m" - ln -s `pwd`/$(filter %$(strip $(patsubst tempinclude/%.h, /%.h, $@)), $(wildcard DataModel/*.h) $(wildcard UserTools/*/*.h) $(wildcard UserTools/*.h)) $@ + ln -s $(SOURCEDIR)/$(filter %$(strip $(patsubst tempinclude/%.h, /%.h, $@)), $(wildcard DataModel/*.h) $(wildcard UserTools/*/*.h) $(wildcard UserTools/*.h)) $@ src/%.o : src/%.cpp $(HEADERS) @echo -e "\e[38;5;214m\n*************** Making " $@ "****************\e[0m" From c2bbf0ba9f7855af97ba8f02543394889365685d Mon Sep 17 00:00:00 2001 From: brichards64 Date: Tue, 26 Mar 2024 01:30:09 +0000 Subject: [PATCH 16/18] added seperator on first line --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 61d2972..1e3acf0 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -SOURCEDIR !=pwd +SOURCEDIR != pwd CXXFLAGS= -fPIC -O3 -Wpedantic -Wall -std=c++11 -Wno-comment -Wno-unused -Wextra -Wcast-align -Wcast-qual -Wctor-dtor-privacy -Wdisabled-optimization -Wformat=2 -Winit-self -Wlogical-op -Wmissing-declarations -Wmissing-include-dirs -Wnoexcept -Woverloaded-virtual -Wredundant-decls -Wshadow -Wsign-conversion -Wsign-promo -Wstrict-null-sentinel -Wstrict-overflow=5 -Wswitch-default -Wundef #-Werror -Wold-style-cast From 31bbbfa3517388cb4aded5e847b3fa644d8d7170 Mon Sep 17 00:00:00 2001 From: brichards64 Date: Tue, 26 Mar 2024 01:58:00 +0000 Subject: [PATCH 17/18] removed != from makefile as centos default make doesnt like it --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 1e3acf0..02d1606 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -SOURCEDIR != pwd +SOURCEDIR:=`pwd` CXXFLAGS= -fPIC -O3 -Wpedantic -Wall -std=c++11 -Wno-comment -Wno-unused -Wextra -Wcast-align -Wcast-qual -Wctor-dtor-privacy -Wdisabled-optimization -Wformat=2 -Winit-self -Wlogical-op -Wmissing-declarations -Wmissing-include-dirs -Wnoexcept -Woverloaded-virtual -Wredundant-decls -Wshadow -Wsign-conversion -Wsign-promo -Wstrict-null-sentinel -Wstrict-overflow=5 -Wswitch-default -Wundef #-Werror -Wold-style-cast From fbb83b54b9f47a056ab7a26f51bd439b95d01a7e Mon Sep 17 00:00:00 2001 From: brichards64 Date: Tue, 26 Mar 2024 02:07:54 +0000 Subject: [PATCH 18/18] rearanged library order becuase ubuntu is shit --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 02d1606..df786fd 100644 --- a/Makefile +++ b/Makefile @@ -19,7 +19,7 @@ TempToolsLib = Includes=-I $(SOURCEDIR)/include/ -I $(SOURCEDIR)/tempinclude/ -Libs=-L $(SOURCEDIR)/lib/ -lStore -lLogging -lToolChain -lDataModelBase -lTempDataModel -lTempTools -lpthread +Libs=-L $(SOURCEDIR)/lib/ -lToolChain -lTempDataModel -lTempTools -lDataModelBase -lLogging -lStore -lpthread LIBRARIES=lib/libStore.so lib/libLogging.so lib/libToolChain.so lib/libDataModelBase.so lib/libTempDataModel.so lib/libTempTools.so HEADERS:=$(patsubst %.h, include/%.h, $(filter %.h, $(subst /, ,$(wildcard src/*/*.h) ))) TempDataModelHEADERS:=$(patsubst %.h, tempinclude/%.h, $(filter %.h, $(subst /, ,$(wildcard DataModel/*.h))))