[gmpi] Re: Linux C++ question

  • From: "Ron Kuper" <RonKuper@xxxxxxxxxxxx>
  • To: <gmpi@xxxxxxxxxxxxx>
  • Date: Wed, 23 Feb 2005 16:17:28 -0500

At what point in the exit sequence does it crash?  Where in the DLL
specifically?

Also, could plugin_list be a map instead?  That would avoid having to
iterate to lookup.

Lastly, is plugin_list a member of class GMPI_Factory?  Pretty please,
m_plugin_list? :-) 

-----Original Message-----
From: gmpi-bounce@xxxxxxxxxxxxx [mailto:gmpi-bounce@xxxxxxxxxxxxx] On
Behalf Of Jeff McClintock
Sent: Wednesday, February 23, 2005 4:14 PM
To: gmpi@xxxxxxxxxxxxx
Subject: [gmpi] Linux C++ question

A question for someone familier (very familier) with C++ on Linux.

A GMPI dll may contain several plugins. In the GMPI prototype.  An 
object called the factory maintains a list.  There is only ever one 
factory.  I used a singleton to implement such.  However Tim reports 
that it crashes while unloading the dll.  Any help appreciated.

details:

The technique comes from "Modern C++ Design - Andrei Alexandrescu", 
author of the Loki library.

This is the essential code.  Ignore the GMPIness of this...If you want 
to see the entire file, let me know.

/* factory is a singleton, this retrieves a pointer to it */
GMPI_Factory *Factory(void)
{
        static GMPI_Factory the_factory;
        return &the_factory;
}

/* register a plugin with this factory */
GMPI_RESULT GMPI_Factory::RegisterPlugin( const GMPI_GUID *iid, 
PLUGIN_CREATE_FUNCTION create_function  )
{
        plugin_list.push_back( pair<const GMPI_GUID 
*,PLUGIN_CREATE_FUNCTION>(iid, create_function) );
        return GMPI_SUCCESS;
}

/* Instantiate a GMPI_Plugin */
GMPI_RESULT GMPI_Factory::CreateInstance( GMPI_GUID *plugin_id, void 
**object )
{
        /* search plugin list for requested type */
        for( list< pair<const GMPI_GUID *,PLUGIN_CREATE_FUNCTION>
>::iterator 
it = plugin_list.begin() ; it != plugin_list.end() ; it++ )
        {
                if( GIMPI_IsEqualIID( plugin_id,  (*it).first ) )
                {
                        /* call plugin create function */
                        GMPI_Plugin *plugin = ((*it).second)();

                        if (plugin == 0)
                        {
                                *object = 0;
                                return GMPI_FAIL;// E_OUTOFMEMORY;
                        }

                    return plugin->QueryInterface( (GMPI_GUID *)
&IID_GMPI_IUnknown , 
object );
                }
        }

        /* couln't find requested type, return error */
        *object = 0;
        return GMPI_FAIL;
}


----------------------------------------------------------------------
Generalized Music Plugin Interface (GMPI) public discussion list
Participation in this list is contingent upon your abiding by the
following rules:  Please stay on topic.  You are responsible for your
own
words.  Please respect your fellow subscribers.  Please do not
redistribute anyone else's words without their permission.

Archive: //www.freelists.org/archives/gmpi
Email gmpi-request@xxxxxxxxxxxxx w/ subject "unsubscribe" to unsubscribe


----------------------------------------------------------------------
Generalized Music Plugin Interface (GMPI) public discussion list
Participation in this list is contingent upon your abiding by the
following rules:  Please stay on topic.  You are responsible for your own
words.  Please respect your fellow subscribers.  Please do not
redistribute anyone else's words without their permission.

Archive: //www.freelists.org/archives/gmpi
Email gmpi-request@xxxxxxxxxxxxx w/ subject "unsubscribe" to unsubscribe

Other related posts: