I have a bunch of classes (a few 10s), that got generated from the .proto files I have. These classes are configuration items. So, let's say I have:
class config_item_1 {
string Id;
...
...
}
class config_item_2 {
string Id;
...
...
}
I have instances of these classes which represent my system configuration. I'm building logic in my code to keep them in-memory, performing some transformations, and at the end, I need to figure out which objects changed. That is, some objects might stay untouched, some might go away, some might change.
So, for all these classes, I need to add a "status" without changing the actual class definitions. Something like a wrapper.
What is the best way to achieve this?
EDIT:
Another "hack" I'm considering is, since my config item classes are generated classes from proto file, like I mentioned, I'm thinking of creating a wrapper proto, like this:
message ConfigCacheItem {
enum ItemState {
UNTOUCHED = 0;
CREATED = 1;
UPDATED = 2;
DELETED = 3;
}
ItemState item_state = 1;
String id = 2; /* ID stashed from one of the items below for lookup */
oneof config_item {
ConfigItem1 config_item_1 = 3;
ConfigItem2 config_item_2 = 4;
....
}
}