Commit a3ed55a3 authored by Micha Müller's avatar Micha Müller
Browse files

Update pluginGeneratorScripts

parent 0a64654a
#!/bin/sh
# This file is part of DCDB (DataCenter DataBase)
# Copyright (C) 2019 Leibniz Supercomputing Centre
cat << EOF > ${PLUGIN_NAME}Configurator.cpp
/*
* ${PLUGIN_NAME}Configurator.cpp
*
* Created on: ${DATE}
* Author: ${AUTHOR}
*/
//================================================================================
// Name : ${PLUGIN_NAME}Configurator.cpp
// Author : ${AUTHOR}
// Copyright :
// Description : Source file for ${PLUGIN_NAME} plugin configurator class.
//================================================================================
//================================================================================
// This file is part of DCDB (DataCenter DataBase)
// Copyright (C) ${DATE} Leibniz Supercomputing Centre
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//================================================================================
#include "${PLUGIN_NAME}Configurator.h"
......@@ -61,24 +82,6 @@ void ${PLUGIN_NAME}Configurator::sensorEntity(${PLUGIN_NAME}${ENTITY_NAME}& s, C
*/
}
}
bool ${PLUGIN_NAME}Configurator::isEntityOfGroup(${PLUGIN_NAME}${ENTITY_NAME}& e, ${PLUGIN_NAME}SensorGroup& g) {
return (g.get${ENTITY_NAME}() == &e);
}
void ${PLUGIN_NAME}Configurator::setEntityForGroup(${PLUGIN_NAME}${ENTITY_NAME}& e, ${PLUGIN_NAME}SensorGroup& g) {
g.set${ENTITY_NAME}(&e);
}
void ${PLUGIN_NAME}Configurator::finalizeGroup(${PLUGIN_NAME}SensorGroup& g) {
/*
* TODO
* Do final configuration of group depending on its entity.
* If not required this method can be removed.
*/
//e.g. configure MQTT depending on entity
//g.setMqttPart(g.get${ENTITY_NAME}()->getMqttPart() + g.getMqttPart());
}
EOF
fi
......@@ -91,24 +94,5 @@ void ${PLUGIN_NAME}Configurator::printConfiguratorConfig(LOG_LEVEL ll) {
* not attributes to log.
*/
LOG_VAR(ll) << " NumSpacesAsIndention: " << 2;
EOF
if [ "$enableEntities" = true ]
then
cat << EOF >> ${PLUGIN_NAME}Configurator.cpp
LOG_VAR(ll) << " ${ENTITY_NAME}s:";
if (_sensorEntitys.size() != 0) {
for(auto e : _sensorEntitys) {
e->printConfig(ll);
}
} else {
LOG_VAR(ll) << " No ${ENTITY_NAME}s present!";
}
EOF
fi
cat << EOF >> ${PLUGIN_NAME}Configurator.cpp
}
EOF
#!/bin/sh
# This file is part of DCDB (DataCenter DataBase)
# Copyright (C) 2019 Leibniz Supercomputing Centre
cat << EOF > ${PLUGIN_NAME}Configurator.h
/*
* ${PLUGIN_NAME}Configurator.h
*
* Created on: ${DATE}
* Author: ${AUTHOR}
*/
//================================================================================
// Name : ${PLUGIN_NAME}Configurator.h
// Author : ${AUTHOR}
// Copyright :
// Description : Header file for ${PLUGIN_NAME} plugin configurator class.
//================================================================================
//================================================================================
// This file is part of DCDB (DataCenter DataBase)
// Copyright (C) ${DATE} Leibniz Supercomputing Centre
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//================================================================================
#ifndef ${PLUGIN_NAME_UPC}_${PLUGIN_NAME_UPC}CONFIGURATOR_H_
#define ${PLUGIN_NAME_UPC}_${PLUGIN_NAME_UPC}CONFIGURATOR_H_
......@@ -22,7 +43,21 @@ fi
cat << EOF >> ${PLUGIN_NAME}Configurator.h
class ${PLUGIN_NAME}Configurator : public ConfiguratorTemplate<${PLUGIN_NAME}SensorBase, ${PLUGIN_NAME}SensorGroup> {
/**
* @brief ConfiguratorTemplate specialization for this plugin.
*
* @ingroup ${PLUGIN_NAME_LWC}
*/
EOF
if [ "$enableEntities" = true ]
then
echo "class ${PLUGIN_NAME}Configurator : public ConfiguratorTemplate<${PLUGIN_NAME}SensorBase, ${PLUGIN_NAME}SensorGroup, ${PLUGIN_NAME}${ENTITY_NAME}> {" >> ${PLUGIN_NAME}Configurator.h
else
echo "class ${PLUGIN_NAME}Configurator : public ConfiguratorTemplate<${PLUGIN_NAME}SensorBase, ${PLUGIN_NAME}SensorGroup> {" >> ${PLUGIN_NAME}Configurator.h
fi
cat << EOF >> ${PLUGIN_NAME}Configurator.h
public:
${PLUGIN_NAME}Configurator();
......@@ -38,16 +73,16 @@ if [ "$enableEntities" = true ]
then
cat << EOF >> ${PLUGIN_NAME}Configurator.h
void sensorEntity(${PLUGIN_NAME}${ENTITY_NAME}& s, CFG_VAL config) override;
bool isEntityOfGroup(${PLUGIN_NAME}${ENTITY_NAME}& e, ${PLUGIN_NAME}SensorGroup& g) override;
void setEntityForGroup(${PLUGIN_NAME}${ENTITY_NAME}& e, ${PLUGIN_NAME}SensorGroup& g) override;
void finalizeGroup(${PLUGIN_NAME}SensorGroup& g) override;
EOF
fi
cat << EOF >> ${PLUGIN_NAME}Configurator.h
//TODO implement if required
//void global(CFG_VAL config) override;
//void derivedSetGlobalSettings(const pluginSettings_t& pluginSettings) override;
void printConfiguratorConfig(LOG_LEVEL ll) override;
void printConfiguratorConfig(LOG_LEVEL ll) final override;
};
extern "C" ConfiguratorInterface* create() {
......
#!/bin/sh
# This file is part of DCDB (DataCenter DataBase)
# Copyright (C) 2019 Leibniz Supercomputing Centre
cat << EOF > ${PLUGIN_NAME}${ENTITY_NAME}.cpp
/*
* ${PLUGIN_NAME}${ENTITY_NAME}.cpp
*
* Created on: ${DATE}
* Author: ${AUTHOR}
*/
//================================================================================
// Name : ${PLUGIN_NAME}${ENTITY_NAME}.h
// Author : ${AUTHOR}
// Copyright :
// Description : Source file for ${PLUGIN_NAME}${ENTITY_NAME} class.
//================================================================================
//================================================================================
// This file is part of DCDB (DataCenter DataBase)
// Copyright (C) ${DATE} Leibniz Supercomputing Centre
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//================================================================================
#include "${PLUGIN_NAME}${ENTITY_NAME}.h"
${PLUGIN_NAME}${ENTITY_NAME}::${PLUGIN_NAME}${ENTITY_NAME}() {
/*
* TODO
* Init attributes
*/
_strand = nullptr;
${PLUGIN_NAME}${ENTITY_NAME}::${PLUGIN_NAME}${ENTITY_NAME}(const std::string& name) :
EntityInterface(name) {
/*
* TODO
* Construct attributes
*/
}
${PLUGIN_NAME}${ENTITY_NAME}::${PLUGIN_NAME}${ENTITY_NAME}(const ${PLUGIN_NAME}${ENTITY_NAME}& other) :
EntityInterface(other) {
/*
* TODO
* Copy construct attributes
*/
}
${PLUGIN_NAME}${ENTITY_NAME}::~${PLUGIN_NAME}${ENTITY_NAME}() {
/*
* TODO
* Tear down attributes
*/
if (_strand) {
delete _strand;
}
/*
* TODO
* Tear down attributes
*/
}
${PLUGIN_NAME}${ENTITY_NAME}& ${PLUGIN_NAME}${ENTITY_NAME}::operator=(const ${PLUGIN_NAME}${ENTITY_NAME}& other) {
EntityInterface::operator=(other);
/*
* TODO
* Implement assignment operator here
*/
return *this;
}
/*
......@@ -35,17 +69,19 @@ ${PLUGIN_NAME}${ENTITY_NAME}::~${PLUGIN_NAME}${ENTITY_NAME}() {
* Implement own methods
*/
void ${PLUGIN_NAME}${ENTITY_NAME}::initializeStrand(boost::asio::io_service& io) {
if (!_strand) {
_strand = new boost::asio::io_service::strand(io);
}
void ${PLUGIN_NAME}${ENTITY_NAME}::execOnInit() {
/*
* TODO
* Implement logic to initialize the entity here or remove method if not required.
* Will be called exactly once at startup.
*/
}
void ${PLUGIN_NAME}${ENTITY_NAME}::printConfig(LOG_LEVEL ll) {
/*
* TODO
* Log attributes here for debug reasons
*/
LOG_VAR(ll) << " NumSpacesAsIndention: " << 3;
void ${PLUGIN_NAME}${ENTITY_NAME}::printEntityConfig(LOG_LEVEL ll) {
/*
* TODO
* Log attributes here for debug reasons
*/
LOG_VAR(ll) << eInd << "Att: " << 3;
}
EOF
#!/bin/sh
# This file is part of DCDB (DataCenter DataBase)
# Copyright (C) 2019 Leibniz Supercomputing Centre
cat << EOF > ${PLUGIN_NAME}${ENTITY_NAME}.h
/*
* ${PLUGIN_NAME}${ENTITY_NAME}.h
*
* Created on: ${DATE}
* Author: ${AUTHOR}
*/
//================================================================================
// Name : ${PLUGIN_NAME}${ENTITY_NAME}.h
// Author : ${AUTHOR}
// Copyright :
// Description : Header file for ${PLUGIN_NAME}${ENTITY_NAME} class.
//================================================================================
//================================================================================
// This file is part of DCDB (DataCenter DataBase)
// Copyright (C) ${DATE} Leibniz Supercomputing Centre
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//================================================================================
#ifndef ${PLUGIN_NAME_UPC}${ENTITY_NAME_UPC}_H_
#define ${PLUGIN_NAME_UPC}${ENTITY_NAME_UPC}_H_
#include <boost/asio.hpp>
#include "../../includes/Logging.h"
#include "../../includes/EntityInterface.h"
class ${PLUGIN_NAME}${ENTITY_NAME} {
/**
* @brief This class handles ${PLUGIN_NAME} ${ENTITY_NAME}.
*
* @ingroup ${PLUGIN_NAME_LWC}
*/
class ${PLUGIN_NAME}${ENTITY_NAME} : public EntityInterface {
public:
${PLUGIN_NAME}${ENTITY_NAME}();
virtual ~${PLUGIN_NAME}${ENTITY_NAME}();
/*
* TODO
* Add methods the entity provides to the SensorGroups.
* Add getter/setter for the attributes as required.
* To make the entity thread safe if called from multiple SensorGroups at
* once, we use a boost::strand. Feel free to get rid of _strand and related
* methods if your entity is already thread safe.
*/
${PLUGIN_NAME}${ENTITY_NAME}(const std::string& name);
${PLUGIN_NAME}${ENTITY_NAME}(const ${PLUGIN_NAME}${ENTITY_NAME}& other);
virtual ~${PLUGIN_NAME}${ENTITY_NAME}();
${PLUGIN_NAME}${ENTITY_NAME}& operator=(const ${PLUGIN_NAME}${ENTITY_NAME}& other);
void initializeStrand(boost::asio::io_service& io);
/*
* TODO
* Add methods the entity provides to the SensorGroups.
* Add getter/setter for the attributes as required.
*/
boost::asio::io_service::strand* getStrand() const { return _strand; }
void execOnInit() final override;
void printConfig(LOG_LEVEL ll);
void printEntityConfig(LOG_LEVEL ll) final override;
private:
/*
* TODO
* Add attributes required for your entity
* If your entity is thread safe you can remove the _strand
*/
boost::asio::io_service::strand* _strand;
LOGGER lg;
/*
* TODO
* Add attributes required for your entity
*/
};
#endif /* ${PLUGIN_NAME_UPC}${ENTITY_NAME_UPC}_H_ */
......
#!/bin/sh
# This file is part of DCDB (DataCenter DataBase)
# Copyright (C) 2019 Leibniz Supercomputing Centre
cat << EOF > ${PLUGIN_NAME}SensorBase.h
/*
* ${PLUGIN_NAME}SensorBase.h
//================================================================================
// Name : ${PLUGIN_NAME}SensorBase.h
// Author : ${AUTHOR}
// Copyright :
// Description : Sensor base class for ${PLUGIN_NAME} plugin.
//================================================================================
//================================================================================
// This file is part of DCDB (DataCenter DataBase)
// Copyright (C) ${DATE} Leibniz Supercomputing Centre
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//================================================================================
/**
* @defgroup ${PLUGIN_NAME_LWC} ${PLUGIN_NAME} plugin
* @ingroup pusherplugins
*
* Created on: ${DATE}
* Author: ${AUTHOR}
* @brief Describe your plugin in one sentence
*/
#ifndef ${PLUGIN_NAME_UPC}_${PLUGIN_NAME_UPC}SENSORBASE_H_
......@@ -52,28 +80,28 @@ public:
*/
}
${PLUGIN_NAME}SensorBase& operator=(const ${PLUGIN_NAME}SensorBase& other) {
SensorBase::operator=(other);
/*
* TODO
* Implement assignment operator for plugin specific attributes
*/
return *this;
}
${PLUGIN_NAME}SensorBase& operator=(const ${PLUGIN_NAME}SensorBase& other) {
SensorBase::operator=(other);
/*
* TODO
* Implement assignment operator for plugin specific attributes
*/
return *this;
}
/*
* TODO
* Getters and Setters for plugin specific attributes
*/
void printConfig(LOG_LEVEL ll, LOGGER& lg) {
/*
* TODO
* Log attributes here for debug reasons
*/
LOG_VAR(ll) << " NumSpacesAsIndention: " << 5;
}
void printConfig(LOG_LEVEL ll, LOGGER& lg) {
/*
* TODO
* Log attributes here for debug reasons
*/
LOG_VAR(ll) << " NumSpacesAsIndention: " << 5;
}
protected:
/*
......
#!/bin/sh
# This file is part of DCDB (DataCenter DataBase)
# Copyright (C) 2019 Leibniz Supercomputing Centre
cat << EOF > ${PLUGIN_NAME}SensorGroup.cpp
/*
* ${PLUGIN_NAME}SensorGroup.cpp
*
* Created on: ${DATE}
* Author: ${AUTHOR}
*/
//================================================================================
// Name : ${PLUGIN_NAME}SensorGroup.cpp
// Author : ${AUTHOR}
// Copyright :
// Description : Source file for ${PLUGIN_NAME} sensor group class.
//================================================================================
//================================================================================
// This file is part of DCDB (DataCenter DataBase)
// Copyright (C) ${DATE} Leibniz Supercomputing Centre
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//================================================================================
#include "${PLUGIN_NAME}SensorGroup.h"
......@@ -14,147 +35,61 @@ cat << EOF > ${PLUGIN_NAME}SensorGroup.cpp
${PLUGIN_NAME}SensorGroup::${PLUGIN_NAME}SensorGroup(const std::string& name) :
SensorGroupTemplate(name) {
EOF
if [ "$enableEntities" = true ]
then
echo " _${ENTITY_NAME_LWC} = nullptr;" >> ${PLUGIN_NAME}SensorGroup.cpp
fi
cat << EOF >> ${PLUGIN_NAME}SensorGroup.cpp
/*
* TODO
* Init attributes
* Construct attributes
*/
}
${PLUGIN_NAME}SensorGroup::${PLUGIN_NAME}SensorGroup(const ${PLUGIN_NAME}SensorGroup& other) :
EOF
if [ "$enableEntities" = true ]
then
echo " SensorGroupTemplate(other)," >> ${PLUGIN_NAME}SensorGroup.cpp
echo " _${ENTITY_NAME_LWC}(other._${ENTITY_NAME_LWC}) {" >> ${PLUGIN_NAME}SensorGroup.cpp
else
echo " SensorGroupTemplate(other) {" >> ${PLUGIN_NAME}SensorGroup.cpp
fi
cat << EOF >> ${PLUGIN_NAME}SensorGroup.cpp
/*
* TODO
* Copy construct attributes
*/
SensorGroupTemplate(other) {
/*
* TODO
* Copy construct attributes
*/
}
${PLUGIN_NAME}SensorGroup::~${PLUGIN_NAME}SensorGroup() {
/*
* TODO
* Tear down attributes
EOF
if [ "$enableEntities" = true ]
then
echo " * But do not delete _${ENTITY_NAME_LWC}! The configurator takes care of it." >> ${PLUGIN_NAME}SensorGroup.cpp
fi
cat << EOF >> ${PLUGIN_NAME}SensorGroup.cpp
*/
}
${PLUGIN_NAME}SensorGroup& ${PLUGIN_NAME}SensorGroup::operator=(const ${PLUGIN_NAME}SensorGroup& other) {
SensorGroupTemplate::operator=(other);
EOF
if [ "$enableEntities" = true ]
then
echo " _${ENTITY_NAME_LWC} = other._${ENTITY_NAME_LWC};" >> ${PLUGIN_NAME}SensorGroup.cpp
fi
cat << EOF >> ${PLUGIN_NAME}SensorGroup.cpp
/*
* TODO
* Implement assignment operator
*/
SensorGroupTemplate::operator=(other);
/*
* TODO
* Implement assignment operator
*/
return *this;
}
void ${PLUGIN_NAME}SensorGroup::start() {
if (_keepRunning) {
//we have been started already
LOG(info) << "Sensorgroup " << _groupName << " already running.";
return;
}
void ${PLUGIN_NAME}SensorGroup::execOnInit() {
/*
* TODO
* Start plugin specific stuff
* Implement one time initialization logic for this group here
* (e.g. allocate memory for buffer) or remove this method if not
* required.
*/
EOF
if [ "$enableEntities" = true ]