Commit d35348f7 authored by Alessio Netti's avatar Alessio Netti
Browse files

Code refactoring (make clean required)

- Added a 'common' directory where all shared code has been placed
- Analytics package has been moved out of dcdbpusher, now has its own makefile
- Some renaming here and there for uniformity
parent 516920a0
......@@ -2,7 +2,7 @@ include config.mk
MAKEFILENAME := $(lastword $(MAKEFILE_LIST))
SUB_DIRS = lib CollectAgent dcdbpusher tools scripts
SUB_DIRS = lib collectagent dcdbpusher analytics tools scripts
CASSANDRA_VERSION = 2.2.10
MOSQUITTO_VERSION = 1.5.5
......@@ -106,7 +106,7 @@ mrproper: distclean
all: check-cross-compile deps $(foreach s,$(SUB_DIRS),$(s)-build)
install: depsinstall $(SUB_DIRS)
@cd include && install $(PUBHEADERS) $(DCDBDEPLOYPATH)/include/dcdb && cd ..
@cd common/include && install $(PUBHEADERS) $(DCDBDEPLOYPATH)/include/dcdb && cd ..
@echo DONE
deps: $(foreach f,$(DISTFILESPATHS),$(DCDBDEPSPATH)/$(f)/.built)
......
......@@ -15,8 +15,8 @@
#include <dlfcn.h>
#include "includes/UnitInterface.h"
#include "includes/AnalyzerConfiguratorInterface.h"
#include "../includes/Logging.h"
#include "../includes/PluginDefinitions.h"
#include "logging.h"
#include "../dcdbpusher/includes/PluginDefinitions.h"
using namespace std;
......
include ../config.mk
include ../common.mk
CXXFLAGS = -std=c++11 -DBOOST_DATE_TIME_POSIX_TIME_STD_CONFIG -DBOOST_NETWORK_ENABLE_HTTPS -O2 -g -Wall -Wno-unused-function -Wno-unused-local-typedefs -Wno-deprecated-declarations -Wno-unused-variable -DBOOST_LOG_DYN_LINK -I$(DCDBBASEPATH)/dcdb/common/include -I$(DCDBDEPLOYPATH)/include -DVERSION=\"$(VERSION)\"
LIBS = -L$(DCDBDEPLOYPATH)/lib/ -ldl -lboost_system -lboost_thread -lboost_log_setup -lboost_log -lboost_regex -lpthread -rdynamic
ANALYZERS = average
ifeq ($(OS),Darwin)
BACNET_PORT = bsd
LIBEXT = dylib
LIBFLAGS = -dynamiclib -install_name
else
BACNET_PORT = linux
LIBEXT = so
LIBFLAGS = -shared -Wl,-soname,
PLUGINFLAGS = -fPIC
endif
ANALYZER_LIBS = $(foreach p,$(ANALYZERS),libdcdbanalyzer_$(p).$(LIBEXT))
all: $(ANALYZER_LIBS)
debug: CXXFLAGS += -DDEBUG
debug: all
clean:
rm -f $(ANALYZER_LIBS) $(shell find . -name "*.o")
$(OBJS) : %.o : %.cpp
install_analyzer: $(ANALYZER_LIBS)
install $^ $(DCDBDEPLOYPATH)/lib/
install_conf: $(foreach p,global $(ANALYZERS),config/$(p).conf)
install -m 644 $^ $(DCDBDEPLOYPATH)/etc/
install: install_analyzer
@echo "Done with installation."
@echo "====================================="
@echo "To copy the configuration files type:"
@echo " > make install_conf"
analyzers/%.o: CXXFLAGS+= $(PLUGINFLAGS)
SensorNavigator.o: CXXFLAGS+= $(PLUGINFLAGS)
libdcdbanalyzer_average.$(LIBEXT): analyzers/average/AverageAnalyzer.o analyzers/average/AverageConfigurator.o ../common/src/sensornavigator.o
$(CXX) $(LIBFLAGS)$@ -o $@ $^ -L$(DCDBDEPLOYPATH)/lib/ -lboost_log -lboost_system -lboost_regex
......@@ -10,7 +10,7 @@
#include "QueryEngine.h"
#include "AnalyzerInterface.h"
#include "../../includes/ConfiguratorInterface.h"
#include "../../dcdbpusher/includes/ConfiguratorInterface.h"
/**
* Interface to configurators for data analyzer plugins
......
......@@ -14,7 +14,7 @@
#include <boost/property_tree/info_parser.hpp>
#include "AnalyzerTemplate.h"
#include "AnalyzerConfiguratorInterface.h"
#include "../../includes/SensorBase.h"
#include "sensorbase.h"
#include <iostream>
#include <sstream>
......
......@@ -11,7 +11,7 @@
#include <map>
#include <boost/asio.hpp>
#include "../../includes/Logging.h"
#include "logging.h"
#include "UnitInterface.h"
using namespace std;
......
......@@ -5,8 +5,8 @@
#ifndef PROJECT_QUERYENGINE_H
#define PROJECT_QUERYENGINE_H
#include "../SensorNavigator.h"
#include "../../includes/SensorBase.h"
#include "sensornavigator.h"
#include "sensorbase.h"
#include <atomic>
using namespace std;
......
......@@ -8,7 +8,7 @@
#include <set>
#include <boost/regex.hpp>
#include <boost/algorithm/string.hpp>
#include "../SensorNavigator.h"
#include "sensornavigator.h"
#include "UnitTemplate.h"
using namespace std;
......
......@@ -6,7 +6,7 @@
#define PROJECT_UNITINTERFACE_H
#include <vector>
#include "../../includes/SensorBase.h"
#include "sensorbase.h"
// Defines how inputs must be constructed for the specified unit
typedef enum inputMode_t { SELECTIVE = 1, ALL = 2, ALL_RECURSIVE = 3 } inputMode_t;
......
include ../config.mk
CXXFLAGS = -O2 -g --std=c++11 -Wall -Wno-unused-local-typedefs -Wno-deprecated-declarations -Wno-unknown-warning-option -fmessage-length=0 -I../include/ -I../lib/include -I$(DCDBDEPLOYPATH)/include -DBOOST_DATE_TIME_POSIX_TIME_STD_CONFIG -DBOOST_LOG_DYN_LINK -I$(DCDBDEPSPATH)/cpp-netlib-0.12.0-final/deps/asio/asio/include -DVERSION=\"$(VERSION)\"
OBJS = collectagent.o \
configuration.o \
logging.o \
sensorcache.o \
simplemqttserver.o \
simplemqttserverthread.o \
simplemqttservermessage.o
CXXFLAGS = -O2 -g --std=c++11 -Wall -Wno-unused-local-typedefs -Wno-deprecated-declarations -Wno-unknown-warning-option -fmessage-length=0 -I../common/include/ -I../lib/include -I$(DCDBDEPLOYPATH)/include -DBOOST_DATE_TIME_POSIX_TIME_STD_CONFIG -DBOOST_LOG_DYN_LINK -I$(DCDBDEPSPATH)/cpp-netlib-0.12.0-final/deps/asio/asio/include -DVERSION=\"$(VERSION)\"
OBJS = ../common/src/logging.o \
../common/src/sensorcache.o \
collectagent.o \
configuration.o \
simplemqttserver.o \
simplemqttserverthread.o \
simplemqttservermessage.o
LIBS = -L$(DCDBDEPLOYPATH)/lib/ -L../lib -ldcdb -pthread -lcassandra -luv -lboost_system -lboost_random -lboost_thread -lboost_date_time -lboost_log_setup -lboost_log -lboost_regex -lcppnetlib-server-parsers -lcppnetlib-uri
TARGET = collectagent
......
......@@ -64,7 +64,7 @@ DCDB::SensorDataStore *mySensorDataStore;
DCDB::SensorConfig *mySensorConfig;
DCDB::SensorCache mySensorCache;
DCDB::SCError err;
DCDBLog::logger_t lg;
logger_t lg;
/* Normal termination (SIGINT, CTRL+C) */
void sigHandler(int sig)
......@@ -296,8 +296,8 @@ int main(int argc, char* const argv[]) {
}
}
DCDBLog::initLogging();
auto cmdSink = DCDBLog::setupCmdLogger();
initLogging();
auto cmdSink = setupCmdLogger();
Configuration config(argv[argc - 1]);
if( !config.readGlobal() ) {
......@@ -343,7 +343,7 @@ int main(int argc, char* const argv[]) {
settings.cassandraSettings.ttl = stoul(optarg);
break;
case 'v':
settings.logLevelCmd = DCDBLog::translateLogLevel(stoi(optarg));
settings.logLevelCmd = translateLogLevel(stoi(optarg));
break;
case 'd':
case 'D':
......@@ -359,7 +359,7 @@ int main(int argc, char* const argv[]) {
}
}
auto fileSink = DCDBLog::setupFileLogger(settings.tempDir, std::string("collectagent"));
auto fileSink = setupFileLogger(settings.tempDir, std::string("collectagent"));
//severity level may be overwritten (per option or config-file) --> set it according to globalSettings
fileSink->set_filter(boost::log::trivial::severity >= settings.logLevelFile);
cmdSink->set_filter(boost::log::trivial::severity >= settings.logLevelCmd);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment