Exemplo n.º 1
0
Server::Server(int port)
 :acceptor(ioService,boost::asio::ip::tcp::endpoint(boost::asio::ip::tcp::v4(), port))
 ,thread(NULL)
 ,timer(ioService)
 ,exited(false)
 ,port(port)
 ,parent(NULL)
{
    // Check for plugins
    typedef IRequestPlugin PluginType;
    typedef boost::shared_ptr<PluginType> PluginPtr;
    typedef PluginFactory::DestroyDeleter<PluginType> Deleter;
    typedef std::vector<PluginPtr> PluginVector;
    //
    PluginVector plugins = PluginFactory::Instance().QueryInterface<PluginType, Deleter>("GetHTTPRequestPlugin");

    for(PluginVector::iterator plugin=plugins.begin();plugin!=plugins.end();++plugin){
        if((*plugin)->WatchPath()){
            this->requestPlugins[(*plugin)->WatchPath()]   = *plugin;
        }else{
            this->requestPlugins[""]   = *plugin;
        }
    }

    // Lets always add the TrackSender
    this->requestPlugins["track"]   = PluginPtr(new TrackSender());

    // Set some options for the acceptor
    boost::asio::socket_base::reuse_address option(true);
    this->acceptor.set_option(option);

}
Exemplo n.º 2
0
void CServer::GetPlugInInstances(const PluginVector & Plugins)
{
	for(PluginVector::const_iterator it = Plugins.begin(); it != Plugins.end(); ++it)
	{
		IServerInterface * Tmp = (*it)->CreateInterface(m_ServerAdress, m_Botname);
		if(Tmp != NULL)
		{
			m_Plugins.push_back(PluginPair(Tmp, (*it)));
		}
	}
}
Exemplo n.º 3
0
static void loadaPlugin(const char *filename, ostream & errstream, bool verbose)
{
	if (verbose && filename)
		errstream << "loading plugin: " << filename << endl;

	DriverDescription::currentfilename = filename;
	DynLoader *dynloader = new DynLoader(filename, errstream, verbose);
	if (!dynloader->valid()) {
		delete dynloader;
		errstream << "Problem during opening of pstoedit driver plugin: " << filename <<
			". This is no problem as long the driver in this library is not needed. Possibly you need to install further libraries and/or extend the LD_LIBRARY_PATH (*nix) or PATH (Windows) environment variables."
			<< endl;
		return;
	} else {
#if defined (__APPLE__)
// on MacOS it seems necessary to at least do a dlsym to an existing symbol 
// to get the global ctors beeing called
		void (*fp) () = ((void (*)()) dynloader->getSymbol("initlibrary"));
		if (fp) {
			if (verbose) {
				errstream << "getSymbol(\"initlibrary\") succeeded." << endl;
			}
		} else {
			errstream << "getSymbol(\"initlibrary\") failed." << endl;
		}
#endif
	}
	LoadedPlugins.add(dynloader);

// this seems to be obsolete. but not with .dll's
//          globalRp->explainformats(errstream);
	if (dynloader->knownSymbol("getglobalRp")) {
		getglobalRpFuncPtr dyngetglobalRpFunc =
			(getglobalRpFuncPtr) dynloader->getSymbol("getglobalRp");
		if (dyngetglobalRpFunc == 0) {
			errstream << "could not find getglobalRp " << endl;
			return;
		}
		DescriptionRegister *dynglobalRp = dyngetglobalRpFunc();
		if (dynglobalRp == 0) {
			errstream << " didn't find any registered Drivers " << endl;
		} else if (dynglobalRp != getglobalRp()) {
//                      globalRp->explainformats(errstream);
			getglobalRp()->mergeRegister(errstream, *dynglobalRp, filename);
		}
	} else {
		// didn't fint getglobalRp
		// so assume that the plug-in does not have
		// it's own copy of globalRp but uses the
		// one from the caller
	}
//          globalRp->explainformats(errstream);
}
Exemplo n.º 4
0
	/// how many plugins?
	int getNPlugins() const
	{
		return (int) _plugins.size();
	}
Exemplo n.º 5
0
	void addPlugin( OfxhPlugin* pe )
	{
		_plugins.push_back( pe );
	}