
Classes | |
| class | Exposer |
| Used as a base class for UI specification. More... | |
| class | Expo |
| Base class for all exposition elements. More... | |
| class | ExposerManifester |
| Used to manifest the UI specified by an Exposer. More... | |
| class | VariableExpo |
| Exposition class used to access a variable. More... | |
| class | PropertyExpo |
| Exposition class used to access a variable which is accessed through a pair of get/set-like methods. More... | |
| class | MethodExpo |
| Exposition class used to access a method taking no arguments. More... | |
There is also a simple Example that demonstrates the use of these constructs. You can download the compiled example (as well as the source code) for Mac OS X and Windows to try it out - see http://sourceforge.net/projects/openexposition/.
Expositions are implemented by the Expo class and its subclasses.
Exposers are implemented by the Exposer class. To create an exposer, either derive the Exposer class and configure the expositions in the constructor of the derived class, or create an instance of the Exposer class and then configure the expositions. When you are done configuring the expositions, you must call the exposer's DoneConstructing method.
First, we define a class with some simple functionality.
class Test { protected: // the flag chooses whether the sum() method will return a+b or a-b bool flag; // a and b are used in the sum function int a; double b; public: Test() {a = 1; b = 2.5; flag=false;} // this method provides the main functionality of this class double sum() {return flag ? a - b : a + b;} // these are the set/get methods that can be used to access the b variable void SetB(double val) {b = val;} double GetB() {return b;} }; // end class Test
We can then derive that class as well as the Exposer class to specify the interface requirements.
class TestExposer : public Test, public Exposer { public: // Whenever an Exposer constructor is called, the instance is pushed on a stack // as the current exposer instance. All instantiated expositions are automatically // assigned to the current exposer. TestExposer(string const &name="Test") : Exposer(name) { // this provides access to a method, which we mark as the "final" action of the exposer *new MethodExpo<double,Test>(*this, &Test::sum, "sum") << new Property(Property::final); // this provides direct access to the flag variable *new VariableExpo<bool>(flag, "flag") << new InfluencesProperty(GetExpo("sum")); // this provides direct access to the a variable *new VariableExpo<int>(a, "a") << new InfluencesProperty(GetExpo("sum")); // this provides access to a variable through a set of get/set methods *new PropertyExpo<double, Test>(*this, &Test::GetB, &Test::SetB, "b") << new InfluencesProperty(GetExpo("sum")); // the following call will mark the end of construction for this exposer DoneConstructing(); } }; // end class TestExposer
An instance of class TestExposer will automatically be manifested through all available exposer manifesters. You can see example screenshots at https://sourceforge.net/project/screenshots.php?group_id=168482.