F
ferdinand.stefanus
Hi
I am writing a C++ class that performs video decoding using a hardware
library. In the library documentation, it is stated that the library
has a function that must be called once before all other functions are
called (let's call it LIBRARY_Init()), and one function that must be
called before the program terminates (e.g. LIBRARY_Cleanup()). I am
thinking of putting something like the following on top of my class'
implementation file:
struct LibraryInitializer
{
LibraryInitializer()
{
LIBRARY_Init();
}
~LibraryInitializer()
{
LIBRARY_Cleanup();
}
};
static const LibraryInitializer init;
//actual class implementation follows...
Is this the correct way to do this? I have a nagging feeling that
there's a better way to do this, but I cannot figure out how.
Thanks!
I am writing a C++ class that performs video decoding using a hardware
library. In the library documentation, it is stated that the library
has a function that must be called once before all other functions are
called (let's call it LIBRARY_Init()), and one function that must be
called before the program terminates (e.g. LIBRARY_Cleanup()). I am
thinking of putting something like the following on top of my class'
implementation file:
struct LibraryInitializer
{
LibraryInitializer()
{
LIBRARY_Init();
}
~LibraryInitializer()
{
LIBRARY_Cleanup();
}
};
static const LibraryInitializer init;
//actual class implementation follows...
Is this the correct way to do this? I have a nagging feeling that
there's a better way to do this, but I cannot figure out how.
Thanks!