M
ma740988
Consider the 'C' source.
void myDoorBellISR(starLinkDevice *slDevice, U32 doorBellVal)
{
doorBellDetected = doorBellVal;
}
void slRcv()
{
starLinkOpenStruct myOpenStruct;
// later
myOpenStruct.starLinkId = FFT_NODE;
myOpenStruct.flags = 0;
myOpenStruct.doorBellCallback = myDoorBellISR;
myOpenStruct.root = PSEUDO_ROOT_NODE;
};
When view from C++ perspective, I'd like pass in myOpenStruct to the
constructor of a class called recv. So now:
int main()
{
// have user setup and pass in the open struct
starLinkOpenStruct myOpenStruct;
myOpenStruct.starLinkId = FFT_NODE;
myOpenStruct.flags = 0;
myOpenStruct.doorBellCallback = myDoorBellISR;
myOpenStruct.root = PSEUDO_ROOT_NODE;
recv* ptr = new recv (myOpenStruct);
}
// recv looks like
class recv
{
public:
recv (starLinkOpenStuct& open_struct)
{
// stuff
}
// more stuff
};
Trouble is doorBellCallBack poses a potential problem, hence I'm trying
to figure out an ideal approach when one of the passed parmams is a
pointer to a function?
Of course another potential issue is the fact that this approach
requires the user to know what the name of the function (in this case
myDoorBellISR) is.
///////
My initial thought
static void myDoorBellISR(starLinkDevice *slDevice,
U32 doorBellVal)
{
doorBellDetected = doorBellVal;
}
class recv
{
public:
recv (starLinkOpenStuct& open_struct)
{
// stuff
}
// more stuff
};
Here again this forces the user to know the name of the
doorBellCallback function. Not good. Help!!
Thanks in advance.
void myDoorBellISR(starLinkDevice *slDevice, U32 doorBellVal)
{
doorBellDetected = doorBellVal;
}
void slRcv()
{
starLinkOpenStruct myOpenStruct;
// later
myOpenStruct.starLinkId = FFT_NODE;
myOpenStruct.flags = 0;
myOpenStruct.doorBellCallback = myDoorBellISR;
myOpenStruct.root = PSEUDO_ROOT_NODE;
};
When view from C++ perspective, I'd like pass in myOpenStruct to the
constructor of a class called recv. So now:
int main()
{
// have user setup and pass in the open struct
starLinkOpenStruct myOpenStruct;
myOpenStruct.starLinkId = FFT_NODE;
myOpenStruct.flags = 0;
myOpenStruct.doorBellCallback = myDoorBellISR;
myOpenStruct.root = PSEUDO_ROOT_NODE;
recv* ptr = new recv (myOpenStruct);
}
// recv looks like
class recv
{
public:
recv (starLinkOpenStuct& open_struct)
{
// stuff
}
// more stuff
};
Trouble is doorBellCallBack poses a potential problem, hence I'm trying
to figure out an ideal approach when one of the passed parmams is a
pointer to a function?
Of course another potential issue is the fact that this approach
requires the user to know what the name of the function (in this case
myDoorBellISR) is.
///////
My initial thought
static void myDoorBellISR(starLinkDevice *slDevice,
U32 doorBellVal)
{
doorBellDetected = doorBellVal;
}
class recv
{
public:
recv (starLinkOpenStuct& open_struct)
{
// stuff
}
// more stuff
};
Here again this forces the user to know the name of the
doorBellCallback function. Not good. Help!!
Thanks in advance.