Runtime Binding

Data change notification is not quite enough. Suppose that clients want to modify the object during program execution without generating code. Code generation complicates the task of attaching multiple heterogeneous clients to server objects. For maximum flexibility in attaching collaborative clients to an object over the Web, a runtime binding mechanism can be added to C++ object access. C++ runtime binding doesn’t degrade the general performance of the running object itself. Remember the advantages of having meta data information available to describe the structure of classes? Well, it can also help automate the runtime binding of compiled C++ classes. The meta data of each class that is to be accessible over the Internet can be used to generate a C structure that enables lookup and access to data members of an object by name (for flexibility) and by index (for speed). Of course, the name can be resolved to an offset index at runtime as an optimization.

In Figure 7 the class represents color, which contains red, green, and blue components. Runtime binding access on member functions is also possible, which can further separate the client presentation from the structure of the object. The runtime binding approach allows you to preserve the performance capability of the C++ object itself while allowing remote dynamic access to the object. All this is possible without introducing appreciable complexity for the class implementor (since the runtime binding structure can be automatically generated using the meta data of the class). This lets you focus on the business logic without concern for the details of making the object’s state externally viewable.

Figure 7 Using Meta Data with Runtime Binding
class Color {
public:
 Color(int r, int g, int b) : red(r), green(g), blue(b) {}
 int getRed() { return red; }
 int getGreen() { return green; }
 int getBlue() { return blue; }
 void setRed(int r) { red = r; }
 void setGreen(int g) { green = g; }
 void setBlue(int b) { blue = b; }

private:
 // ‘callback enabledÓ data members
 IntData red;
 IntData green;
 IntData blue;
};