MXS-1461 Template Module -> class Module + template SpecificModule
This commit is contained in:
parent
25e288b571
commit
604502e1cb
@ -23,7 +23,7 @@ namespace maxscale
|
||||
/**
|
||||
* An instance of FilterModule represents a filter module.
|
||||
*/
|
||||
class FilterModule : public Module<FilterModule>
|
||||
class FilterModule : public SpecificModule<FilterModule>
|
||||
{
|
||||
FilterModule(const FilterModule&);
|
||||
FilterModule& operator = (const FilterModule&);
|
||||
@ -184,7 +184,7 @@ private:
|
||||
}
|
||||
|
||||
private:
|
||||
friend class Module<FilterModule>;
|
||||
friend class SpecificModule<FilterModule>;
|
||||
|
||||
FilterModule(MXS_FILTER_OBJECT* pApi)
|
||||
: m_pApi(pApi)
|
||||
|
@ -19,18 +19,10 @@ namespace maxscale
|
||||
{
|
||||
|
||||
/**
|
||||
* The template Module is an abstraction for a MaxScale module, to
|
||||
* be used as the base class of a concrete module.
|
||||
* The class Module is an abstraction for a MaxScale module, to
|
||||
* be used as the base class of a specific module.
|
||||
*/
|
||||
template<class T>
|
||||
class Module;
|
||||
|
||||
/**
|
||||
* The template specialization Module<void> provides functionality common
|
||||
* to all modules.
|
||||
*/
|
||||
template <>
|
||||
class Module<void>
|
||||
class Module
|
||||
{
|
||||
public:
|
||||
/**
|
||||
@ -74,7 +66,7 @@ public:
|
||||
* The template Module is intended to be derived from using the derived
|
||||
* class as template argument.
|
||||
*
|
||||
* class XyzModule : public Module<XyzModule> { ... }
|
||||
* class XyzModule : public SpecificModule<XyzModule> { ... }
|
||||
*
|
||||
* @param zFile_name The name of the module.
|
||||
*
|
||||
@ -82,14 +74,14 @@ public:
|
||||
* the expected type.
|
||||
*/
|
||||
template<class T>
|
||||
class Module
|
||||
class SpecificModule : public Module
|
||||
{
|
||||
public:
|
||||
static std::auto_ptr<T> load(const char* zFile_name)
|
||||
{
|
||||
std::auto_ptr<T> sT;
|
||||
|
||||
void* pApi = Module<void>::load(zFile_name, T::zName);
|
||||
void* pApi = Module::load(zFile_name, T::zName);
|
||||
|
||||
if (pApi)
|
||||
{
|
||||
@ -98,6 +90,11 @@ public:
|
||||
|
||||
return sT;
|
||||
}
|
||||
|
||||
protected:
|
||||
SpecificModule()
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ namespace maxscale
|
||||
* A QueryClassfierModule instance is an abstraction for a query
|
||||
* classifier module.
|
||||
*/
|
||||
class QueryClassifierModule : public Module<QueryClassifierModule>
|
||||
class QueryClassifierModule : public SpecificModule<QueryClassifierModule>
|
||||
{
|
||||
QueryClassifierModule(const QueryClassifierModule&);
|
||||
QueryClassifierModule& operator = (const QueryClassifierModule&);
|
||||
@ -34,7 +34,7 @@ public:
|
||||
typedef QUERY_CLASSIFIER type_t; /*< The type of the module object. */
|
||||
|
||||
private:
|
||||
friend class Module<QueryClassifierModule>;
|
||||
friend class SpecificModule<QueryClassifierModule>;
|
||||
|
||||
QueryClassifierModule(QUERY_CLASSIFIER* pApi)
|
||||
: m_pApi(pApi)
|
||||
|
@ -18,13 +18,13 @@ namespace maxscale
|
||||
{
|
||||
|
||||
//static
|
||||
void* Module<void>::load(const char* zName, const char* zType)
|
||||
void* Module::load(const char* zName, const char* zType)
|
||||
{
|
||||
return load_module(zName, zType);
|
||||
}
|
||||
|
||||
//static
|
||||
bool Module<void>::process_init()
|
||||
bool Module::process_init()
|
||||
{
|
||||
bool initialized = false;
|
||||
|
||||
@ -69,7 +69,7 @@ bool Module<void>::process_init()
|
||||
}
|
||||
|
||||
//static
|
||||
void Module<void>::process_finish()
|
||||
void Module::process_finish()
|
||||
{
|
||||
MXS_MODULE_ITERATOR i = mxs_module_iterator_get(NULL);
|
||||
MXS_MODULE* module = NULL;
|
||||
@ -84,7 +84,7 @@ void Module<void>::process_finish()
|
||||
}
|
||||
|
||||
//static
|
||||
bool Module<void>::thread_init()
|
||||
bool Module::thread_init()
|
||||
{
|
||||
bool initialized = false;
|
||||
|
||||
@ -129,7 +129,7 @@ bool Module<void>::thread_init()
|
||||
}
|
||||
|
||||
//static
|
||||
void Module<void>::thread_finish()
|
||||
void Module::thread_finish()
|
||||
{
|
||||
MXS_MODULE_ITERATOR i = mxs_module_iterator_get(NULL);
|
||||
MXS_MODULE* module = NULL;
|
||||
|
@ -927,9 +927,9 @@ int run()
|
||||
|
||||
if (sModule.get())
|
||||
{
|
||||
if (maxscale::Module<void>::process_init())
|
||||
if (maxscale::Module::process_init())
|
||||
{
|
||||
if (maxscale::Module<void>::thread_init())
|
||||
if (maxscale::Module::thread_init())
|
||||
{
|
||||
rv = 0;
|
||||
rv += test(*sModule.get());
|
||||
@ -939,14 +939,14 @@ int run()
|
||||
rv += test_on_queries(*sModule.get());
|
||||
}
|
||||
|
||||
maxscale::Module<void>::thread_finish();
|
||||
maxscale::Module::thread_finish();
|
||||
}
|
||||
else
|
||||
{
|
||||
cerr << "error: Could not perform thread initialization." << endl;
|
||||
}
|
||||
|
||||
maxscale::Module<void>::process_finish();
|
||||
maxscale::Module::process_finish();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user