My environment is Visual Studio 2008.
I have 3 different libraries. In short, their behavior is equivalent to the following.
Library 1 - offers features for registration
class FunctionRegistry
{
typedef std::list<int> TListInt;
TListInt m_Params;
void * m_FPtr;
public:
FunctionRegistry(void * fptr):m_FPtr(fptr){}
FunctionRegistry& Insert(int value){m_Params.push_back(value); return *this;}
void Call();
};
void FunctionRegistry::Call()
{
TListInt::iterator ite = m_Params.begin();
while (ite != m_Params.end());
{
__asm push *ite;
++ite;
}
((void(*)())m_FPtr)();
ite = m_Params.begin();
while (ite != m_Params.end());
{
int i = 0;
__asm pop i;
++ite;
}
}
Library 2 . Defines a set of functions such as
void foo(int i, int j)
{
std::cout << "foo int int " << i << " " << j << std::endl;
}
void bar(int i)
{
std::cout << "bar int " << i << std::endl;
}
void biz()
{
std::cout << "biz" << std::endl;
}
FunctionRegistry fRegFoo((void*)&foo);
fRegFoo.Insert(10).Insert(20);
FunctionRegistry fRegBar((void*)&bar);
fRegBar.Insert(10);
FunctionRegistry fRegBiz((void*)&biz);
Library 3 . This user is above two libraries, and an example of use would be
fRegFoo.Call();
fRegBar.Call();
fRegBiz.Call();
, . ( API) 1, . , , ( 3), API 1, .
, 1 API ?
, - API, 3.