So an Instanced API is one that behaves like an object. So for example:
foo* GetInstancedAPI();
void MemFuncSetter(foo* fooThis, const int arg);
int MemFuncGetter(const foo* fooThis) const;
This is as opposed to a non-instanced API which would depend upon look-ups:
int GetInstancedAPI();
void MemFuncSetter(const int index, const int arg);
int MemFuncGetter(const int index) const;
A little background about the situation, this is a C API, that's being used to wrap a C++ implementation. So internally to the implementation I am working with objects. So I've tried to think through the ramifications of each, the biggest issues I can think of are:
- How would I handle callbacks?
- Is there a way minimize the lookup cost?
Edit:
There have been a lot of requests for clarifications: foo*
is really a void
pointer in the C interface which will be reinterpret_cast
into a pointer to the actual C++ object, thus it must be passed in.
The functions that take an int
are with the intention of indexing into an vector
of objects in the wrapped C++.