Commit 96d5cb54 authored by mr-ti's avatar mr-ti
Browse files

No commit message

No commit message
parent a56f7e06
......@@ -2,7 +2,7 @@
PROJECT(ddnssync)
# ### COMMUN ###
SET(ddnssync_SRCS main.cpp)
SET(ddnssync_SRCS main.cpp ddnssslist.cpp)
SET(ddnssync_LIBS ddnssbase unicomdb)
SET(ddnssync_DEFS ${global_unicomctrl_DEFS})
SET(ddnssync_LDFS )
......
//
// C++ Implementation: cunipluginlib
//
// Description:
//
//
// Author: Emeric Verschuur <ct-info@mr-ti.com>, (C) 2007
//
// Copyright: See COPYING file that comes with this distribution
//
//
#include "cunipluginlib.h"
#include <stdlib.h>
#ifndef WIN32
#include <dlfcn.h>
#endif
/**
* @brief CUniPlugin constructor.
* @param config Configuration.
* @param path Plugin path.
* @param name Plugin name.
*/
CUniPlugin::CUniPlugin(void *handle, ExecFct execFct):CUniObj(){
}
/**
* @brief CUniPlugin destructor.
*/
CUniPlugin::~CUniPlugin(){
}
/**
* @brief The name of the class.
* @return "CUniPlugin"
*/
string CUniPlugin::className() {
return "CUniPlugin";
}
//
// C++ Interface: cunipluginlib
//
// Description:
//
//
// Author: Emeric Verschuur <ct-info@mr-ti.com>, (C) 2007
//
// Copyright: See COPYING file that comes with this distribution
//
//
/**
* @author Emeric VERSCHUUR <contact@mr-ti.com>, (C) 2007
*/
#ifndef DDNSSPLUGIN_H
#define DDNSSPLUGIN_H
/**
* @brief
*/
class CUniPlugin:public CUniObj{
public:
typedef void (*ExecFct)(const string&);
CUniPlugin(void *handle, ExecFct execFct);
~CUniPlugin();
ExecFct exec;
virtual string className();
private:
void *handle;
};
#endif
//
// C++ Implementation: cunipluginlist
//
// Description:
//
//
// Author: Emeric Verschuur <ct-info@mr-ti.com>, (C) 2007
//
// Copyright: See COPYING file that comes with this distribution
//
//
#include "cunipluginlist.h"
#include "cunipluginpus.h"
#include "cunipluginlib.h"
/**
* @brief CUniPlugin constructor.
*/
CUniPluginList::CUniPluginList(CUniConf *config):CUniObj(),map<string,CUniPlugin *>() {
this->config=config;
string dirPath=config->getValue("plugin_dir_path");
if(!dirPath.empty()){
CUniStringList list=config->getListValue("plugin_dlib_list");
for(CUniStringList::iterator it=list.begin();it!=list.end();it++){
insert(make_pair(*it,new CUniPluginLib(config,dirPath+"/"+*it,*it)));
}
list=config->getListValue("plugin_exe_list");
for(CUniStringList::iterator it=list.begin();it!=list.end();it++){
insert(make_pair(*it,new CUniPluginPus(config,dirPath+"/"+*it,*it)));
}
}else{
printc("The \"plugin_dir_path\" is empty !\n");
}
}
/**
* @brief CUniPlugin destructor.
*/
CUniPluginList::~CUniPluginList() {
stopAll();
for(iterator it=begin();it!=end();it++){
delete it->second;
}
}
/**
* @brief Function to call at initialization.
*/
void CUniPluginList::init(){
CUniStringList list=config->getListValue("plugin_at_start_list");
for(CUniStringList::iterator it=list.begin();it!=list.end();it++){
start(*it);
}
}
/**
* @brief Start (Load) a plugin.
* @param name Plugin name.
* @return true if the plugin is started correctly, otherwise false.
*/
bool CUniPluginList::start(const string &name) {
iterator it=find(name);
if(it!=end()){
if(it->second->start()){
return true;
}else{
lastError=it->second->getLastError();
return false;
}
}else{
lastError="Plugin don't exist !";
return false;
}
}
/**
* @brief Stop (Unload) a plugin.
* @param name Plugin name.
* @return true if the plugin is stopped correctly, otherwise false.
*/
bool CUniPluginList::stop(const string &name) {
iterator it=find(name);
if(it!=end()){
if(it->second->stop()){
return true;
}else{
lastError=it->second->getLastError();
return false;
}
}else{
lastError="Plugin don't exist !";
return false;
}
}
/**
* @brief Start (Load) all plugins.
*/
void CUniPluginList::startAll() {
for(iterator it=begin();it!=end();it++)
it->second->start();
}
/**
* @brief Stop (Unload) all plugins.
*/
void CUniPluginList::stopAll() {
for(iterator it=begin();it!=end();it++)
it->second->stop();
}
/**
* @brief Get a 2D list within the state of all plugins.
*/
void CUniPluginList::getStateList(CUniString2DList &list2d) {
CUniStringList tmp;
for(iterator it=begin();it!=end();it++){
it->second->getState(tmp);
list2d.push_back(tmp);
tmp.clear();
}
}
/**
* @brief Get the last Error.
* @return a reference to the last error string.
*/
const string& CUniPluginList::getLastError(){
return lastError;
}
/**
* @brief The name of the class.
* @return "CUniPluginList"
*/
string CUniPluginList::className() {
return "CUniPluginList";
}
//
// C++ Interface: cunipluginlist
//
// Description:
//
//
// Author: Emeric Verschuur <ct-info@mr-ti.com>, (C) 2007
//
// Copyright: See COPYING file that comes with this distribution
//
//
/**
* @brief Plugin list management.
* @file cunipluginlist.h
* @author Emeric VERSCHUUR <contact@mr-ti.com>, (C) 2007
* @date 29/07/2007
*/
#ifndef CUNIPLUGINLIST_H
#define CUNIPLUGINLIST_H
#include "cuniplugin.h"
#include <map>
/**
* This class can manage a plugin list.
* @brief Plugin list.
*/
class CUniPluginList : public CUniObj, public map<string,CUniPlugin *> {
public:
CUniPluginList(CUniConf &config);
~CUniPluginList();
bool start(const string &name);
void init();
bool stop(const string &name);
void startAll();
void stopAll();
void getStateList(CUniString2DList &list2d);
const string &getLastError();
virtual string className();
private:
map<string,CUniPlugin *>
};
#endif
......@@ -51,7 +51,12 @@ DDnsSSList::DName::~DName()
}
virtual int DDnsSSList::DName::run(){
int DDnsSSList::DName::run(){
}
void DDnsSSList::DName::onExit(){
}
......
......@@ -14,6 +14,7 @@
#include <unicomctrl/cunithread.h>
#include <unicomctrl/cuniconf.h>
#include <unicomctrl/unilib.h>
/**
@author Emeric VERSCHUUR <contact@mr-ti.com>
......@@ -28,6 +29,7 @@ public:
virtual string className();
protected:
virtual int run();
virtual void onExit();
private:
string dname;
CUniStringList cmdList;
......
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