On Wed, 17 Dec 2008, Guy K. Kloss wrote:
>
>> If you are using an object oriented
>> language and lcms supports passing a pointer then you can pass the
>> address of 'this' object and the callback function can then invoke a
>> well known method name on the object so that the error is handled by
>> the correct object. This avoids any use of a global variable.
>
> But it would still require registering a callback target (or object that has
> got a target)? If so, then competing calls in a multi threaded application
> could potentially result in a misdirected error callback invocation.

It is true that with this approach only one C callback function can be 
registered at one time.  Via inheritance, several different types of 
objects can simultaneously use lcms.  If lcms was written in C++ then 
it could provide a base class for callback objects (avoiding a global 
registration entirely) but since it is written in C, a function with 
C-language binding needs to then invoke a C++ class method (or 
dispatch to Python, Perl, etc).

The other solution is to not use a callback at all and rely entirely 
on data stuffed into a user supplied error report buffer.  This makes 
it difficult to do things like aborting further processing unless the 
desired behaviors can be fully parameterized.  There is the option of 
a mixed solution where both a buffer and a callback function are 
passed for each call to lcms, and the callback function is provided 
with a pointer to the buffer.

Bob
======================================
Bob Friesenhahn
bfrie...@simple.dallas.tx.us, http://www.simplesystems.org/users/bfriesen/
GraphicsMagick Maintainer,    http://www.GraphicsMagick.org/


------------------------------------------------------------------------------
SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada.
The future of the web can't happen without you.  Join us at MIX09 to help
pave the way to the Next Web now. Learn more and register at
http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/
_______________________________________________
Lcms-user mailing list
Lcms-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/lcms-user

Reply via email to