Mac Forums

Mac Forums (http://www.mac-forums.com/forums/)
-   OS X - Development and Darwin (http://www.mac-forums.com/forums/os-x-development-darwin/)
-   -   boost member function problem (http://www.mac-forums.com/forums/os-x-development-darwin/135585-boost-member-function-problem.html)

BillMcLean 01-02-2009 05:48 PM

boost member function problem
 
I'm trying to code up a FSEvent callback using a member function.

I am using both the boost::bind and boost::function libraries. I have the following declaration for declaring the signature of the FSEventCallback:


Quote:

typedef boost::function<(
ConstFSEventStreamRef streamRef, // _1
void *clientCallBackInfo, // _2
size_t numEvents, // _3
void *eventPaths, // _4
const FSEventStreamEventFlags eventFlags[], // _5
const FSEventStreamEventId eventIds[] // _6
)> FSEventCallbackT;


The skeleton of the struct that has the member function that I want the member function to be called looks like:


Quote:

struct osx::detail {
// Callback type definition

static const CFAbsoluteTime LATENCY = 2.0;
static const unsigned BUF_SIZE = 32768;
CFStringRef pathToWatch;
CFArrayRef pathsToWatch;
FSEventStreamRef streamRef;
void *callbackInfo;
CFRunLoopRef mainLoop;
boost::mutex event_mutex;
typedef boost::mutex::scoped_lock lock_type;
FSEventCallbackT callBack;
// public methods

detail(
const boost::filesystem::path& base_path
);

~detail() {
stop();
// destructor is guaranteed not to be called while get_item() is
// active in another thread
}

void stop();


void FSEventTriggered(
ConstFSEventStreamRef streamRef, // _1
void *clientCallBackInfo, // _2
size_t numEvents, // _3
void *eventPaths, // _4
const FSEventStreamEventFlags eventFlags[], // _5
const FSEventStreamEventId eventIds[] // _6
);

item get_item();
};


In the constructor I get a single compile in the call FSEventStreamCreate:


Quote:

osx::detail::detail(
const boost::filesystem::path& base_path
) :
base_path(base_path),
stopped(false),
pathToWatch(CFStringCreateWithCString(NULL,base_pa th.string().c_str(), kCFStringEncodingUTF8)),
pathsToWatch(CFArrayCreate(NULL, (const void **) &pathToWatch, 1, NULL))
{
callBack = boost::bind(&fsmon :: osx::detail::FSEventTriggered, this, _1, _2, _3, _4, _5, _6);
streamRef = FSEventStreamCreate(NULL,
&callBack,
callbackInfo,
pathsToWatch,
kFSEventStreamEventIdSinceNow,
LATENCY,
kFSEventStreamCreateFlagNone
);


/Users/bill/ardev/CurrentDev/InternalLibs/fsmon/osxExample.cpp:111: error: cannot convert 'FSEventCallbackT*' to 'void (*)(const __FSEventStream*, void*, size_t, void*, const FSEventStreamEventFlags*, const FSEventStreamEventId*)' for argument '2' to '__FSEventStream* FSEventStreamCreate(const __CFAllocator*, void (*)(const __FSEventStream*, void*, size_t, void*, const FSEventStreamEventFlags*, const FSEventStreamEventId*), FSEventStreamContext*, const __CFArray*, FSEventStreamEventId, CFTimeInterval, FSEventStreamCreateFlags)'

Frankly I am stumped.

Bill


All times are GMT -4. The time now is 12:06 PM.

Powered by vBulletin
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.