[gmpi] Re: Linux C++ question

  • From: "B.J. Buchalter" <bj@xxxxxxxxxx>
  • To: "gmpi@xxxxxxxxxxxxx" <gmpi@xxxxxxxxxxxxx>
  • Date: Wed, 23 Feb 2005 17:05:31 -0500

on 2/23/05 4:47 PM, Jeff McClintock at jeffmcc@xxxxxxxxxx wrote:

>> Also, could plugin_list be a map instead?  That would avoid having to
>> iterate to lookup.
> 
> Hmm, don't work quite as expected.  Map contains pointers to GUIDs. Two
> GUID's may contain the same value, but the lookup fails because the map
> is testing equality of the pointers.

You need to define a comparison operator for the GUID pointer type, and then
pass define the set template with the operator:

typedef GMPI_GUID* GMPI_GUIDPtr;

struct GUIDPtr_Comp : std::binary_function<GMPI_GUIDPtr, GMPI_GUIDPtr, bool>
{
    bool operator()(const GMPI_GUIDPtr& x, const GMPI_GUIDPtr& y) const
            {return static_cast<bool>(
                  // code here compares the values pointed to by x and y,
                  // returning true when x < y
                        );
    }
};

typedef std::map<GMPI_GUID*, PLUGIN_CREATE_FUNCTION, GUIDPtr_Comp>
                                                    GMPI_creator_list_type;

and use GMPI_creator_list_type in place of the plug-in list in the original
code.

This code may not actually compile, but it is extracted from code that
actually compiles and does the task that has been described...

Best regards,


B.J. Buchalter

Metric Halo
5 Donovan Drive
Hopewell Junction, NY 12533 USA
tel +1 845 223-6112
fax +1 603 250-2451


----------------------------------------------------------------------
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: