metaproxy  1.3.55
Classes | Public Member Functions | Private Types | Private Attributes | List of all members
metaproxy_1::FactoryFilter Class Reference

#include <factory_filter.hpp>

Inheritance diagram for metaproxy_1::FactoryFilter:
Inheritance graph
Collaboration diagram for metaproxy_1::FactoryFilter:
Collaboration graph

Classes

class  NotFound
class  Rep

Public Member Functions

 FactoryFilter ()
 true if registration ok
 ~FactoryFilter ()
bool add_creator (const std::string &fi, CreateFilterCallback cfc)
bool drop_creator (std::string fi)
metaproxy_1::filter::Base * create (std::string fi)
bool exist (std::string fi)
bool add_creator_dl (const std::string &fi, const std::string &path)
bool have_dl_support ()

Private Types

typedef
metaproxy_1::filter::Base *(* 
CreateFilterCallback )()

Private Attributes

boost::scoped_ptr< Repm_p

Detailed Description

Definition at line 33 of file factory_filter.hpp.

Member Typedef Documentation

typedef metaproxy_1::filter::Base*(* metaproxy_1::FactoryFilter::CreateFilterCallback)()
private

Definition at line 35 of file factory_filter.hpp.

Constructor & Destructor Documentation

metaproxy_1::FactoryFilter::FactoryFilter ( )

true if registration ok

Definition at line 59 of file factory_filter.cpp.

: m_p(new mp::FactoryFilter::Rep)
{
}
metaproxy_1::FactoryFilter::~FactoryFilter ( )

Definition at line 64 of file factory_filter.cpp.

{
}

Member Function Documentation

bool metaproxy_1::FactoryFilter::add_creator ( const std::string &  fi,
CreateFilterCallback  cfc 
)

Definition at line 69 of file factory_filter.cpp.

Referenced by metaproxy_1::FactoryStatic::FactoryStatic().

{
return m_p->m_fcm.insert(Rep::CallbackMap::value_type(fi, cfc)).second;
}
bool metaproxy_1::FactoryFilter::add_creator_dl ( const std::string &  fi,
const std::string &  path 
)

Definition at line 113 of file factory_filter.cpp.

{
#if HAVE_DLFCN_H
if (m_p->m_fcm.find(fi) != m_p->m_fcm.end())
{
return true;
}
std::string full_path = path + "/metaproxy_filter_" + fi + ".so";
void *dl_handle = dlopen(full_path.c_str(), RTLD_GLOBAL|RTLD_NOW);
if (!dl_handle)
{
const char *dl = dlerror();
std::cout << "dlopen " << full_path << " failed. dlerror=" << dl <<
std::endl;
return false;
}
std::string full_name = "metaproxy_1_filter_" + fi;
void *dlsym_ptr = dlsym(dl_handle, full_name.c_str());
if (!dlsym_ptr)
{
std::cout << "dlsym " << full_name << " failed\n";
return false;
}
struct metaproxy_1_filter_struct *s = (struct metaproxy_1_filter_struct *) dlsym_ptr;
return add_creator(fi, s->creator);
#else
return false;
#endif
}
mp::filter::Base * metaproxy_1::FactoryFilter::create ( std::string  fi)

Definition at line 92 of file factory_filter.cpp.

{
Rep::CallbackMap::const_iterator it = m_p->m_fcm.find(fi);
if (it == m_p->m_fcm.end()){
std::string msg = "filter type '" + fi + "' not found";
throw NotFound(msg);
}
// call create function
return (it->second());
}
bool metaproxy_1::FactoryFilter::drop_creator ( std::string  fi)

Definition at line 76 of file factory_filter.cpp.

{
return m_p->m_fcm.erase(fi) == 1;
}
bool metaproxy_1::FactoryFilter::exist ( std::string  fi)

Definition at line 81 of file factory_filter.cpp.

{
Rep::CallbackMap::const_iterator it = m_p->m_fcm.find(fi);
if (it == m_p->m_fcm.end())
{
return false;
}
return true;
}
bool metaproxy_1::FactoryFilter::have_dl_support ( )

Definition at line 104 of file factory_filter.cpp.

{
#if HAVE_DLFCN_H
return true;
#else
return false;
#endif
}

Member Data Documentation

boost::scoped_ptr<Rep> metaproxy_1::FactoryFilter::m_p
private

Definition at line 60 of file factory_filter.hpp.


The documentation for this class was generated from the following files: