V
Vikas
Hi y'all,
I have an existing GUI application where various windows has columns
which are mapped to data members of various classes. Now, I have to
implement a new functionality to all the classes and I was wondering
if I can somehow map the data member fields to the column ids.
Following code illustrates the question.
// Existing code
// Constants for window columns
const int COL_A 1;
const int COL_B 2;
const int COL_C 3;
....
<const for other columns>
// classes whose member fields holds the data of the columns
class foo
{
public:
string a;
string b;
int c;
...
<other data member corresponding to columns>
};
now at run_time I need to do something like the following:
// New functionality
void bar(int col_id, int val)
{
int field_val = mapping_to_get_value_based_on_col_id();
if (field_val == val)
new_functionality();
}
I am having a hard time to find a generic wasy to do the mapping. I
know, I can have a switch statement for all the classes where based on
col number I get the field value but it will be nice to have a simple,
generic way.
Thanks for your replies.
Vikas
I have an existing GUI application where various windows has columns
which are mapped to data members of various classes. Now, I have to
implement a new functionality to all the classes and I was wondering
if I can somehow map the data member fields to the column ids.
Following code illustrates the question.
// Existing code
// Constants for window columns
const int COL_A 1;
const int COL_B 2;
const int COL_C 3;
....
<const for other columns>
// classes whose member fields holds the data of the columns
class foo
{
public:
string a;
string b;
int c;
...
<other data member corresponding to columns>
};
now at run_time I need to do something like the following:
// New functionality
void bar(int col_id, int val)
{
int field_val = mapping_to_get_value_based_on_col_id();
if (field_val == val)
new_functionality();
}
I am having a hard time to find a generic wasy to do the mapping. I
know, I can have a switch statement for all the classes where based on
col number I get the field value but it will be nice to have a simple,
generic way.
Thanks for your replies.
Vikas