Hi all,
My application uses an int
as id to identify objects in both in-memory and persistent registry. Functions in the application receive the id as argument, retrieve the object from the registry and do their job, e.g.
void print( int id, int bar, double zip, int boo )
{
Object *obj = get_obj_by_id( id );
obj->print( bar, zip, boo );
}
The application has evolved and now it is possible to have more than one registry in the same application. The application now uses a globally accessible 'current' registry, which, as globals tend to do, causes a lot of trouble.
To get rid of the concept of a global 'current' registry, I would need to introduce a type that uniquely identifies the object across registries. I cannot change the value of the int
that is being used, so I have to create a full_id
type from the int
id and an identification of the registry.
The example function hence would have to change to
void print( full_id id, int bar, double zip, int boo )
{
Object *obj = get_obj_by_id( id );
obj->print( bar, zip, boo );
}
There are conventions about the naming of id arguments, but these are not rigorously followed throughout the application, so I cannot make assumptions about the name of the id argument, or that it is always the first argument. Also there are many many functions that that have to be changed. What is the most efficient and reliable way to replace the int
typed ids by full_id
typed ids?