Creating a handle for an object? How?
I have these function definitions and I'm supposed to write the functions. I have trouble understanding a part of it. I will explain.
I am planning on creating a class and in the implementation of the create function, I will set a variable to current time (using gettickcount () ) and set the expiry variable to what's passed in. In the isExpired function, I will compare the values against current time (again using gettickcount () ) and determine if timer is expired or not.
But I don't know how to create a handle for each timer the way the function definitions require me to. Any ideas?
Re: Creating a handle for an object? How?
Not enough info. What OS? Are the timers implemented by the OS or have ou implemented them?
A handle is just something the computer uses to be able to identify an object. It could be a pointer, or it could just be a number that indexes into a pointer or object table. For example:
1-4 could be considered "handles" in this respect. The exact meaning of handle in your situation will depend on the situation, for example if these are Windows handles as implemented by the WinAPI, then the HANDLEs returned by CreateTimer() et al would count as valid handles that could be returned by your functions, unless for any reason you wanted to obfuscate the actual Windows HANDLE values themselves, in which case you'd want to create a lookup table so that your program could deduce the Windows HANDLE from the handle passed in, e.g.
then your program would get a Windows HANDLE and bung it in this table, return as a handle the lookup value, then on each entry to your library you would take the given handle (1-3) and lookup the actual Windows HANDLE which you would then use to call the Windows function.
Bit rambly but I hope that's clear ;-)
|All times are GMT +5.5. The time now is 10:53.|