Listing 3: CABLE configuration file
// countertcl_config.cxx // CABLE input file to build CounterTcl package. // Define Counter class in-line in the configuration file. template <typename T> class Counter { public: Counter(): value(0) {} T Get() const { return value; } void Set(T v) { value = v; } void Reset() { value = 0; } void Increment() { ++value; } private: T value; }; // The symbol "CABLE_CONFIGURATION" is defined only when CABLE is // reading this file. Place the CABLE-specific code inside this // section so it cannot be seen by the compiler. #ifdef CABLE_CONFIGURATION namespace _cable_ { // Specify package name. Group configuration allows multiple // configuration files to define wrappers for a single package. const char* const group="CounterTcl1"; const char* const package="CounterTcl"; const char* const groups[]={"CounterTcl1"}; namespace wrappers { // Tell CABLE what instantiations to wrap, and what the class // wrappers should be called. typedef Counter<int> Counter_int; typedef Counter<float> Counter_float; } } // Make sure the Counter instantiations are complete types so that all // the methods are available. void _cable_instantiate() { sizeof(_cable_::wrappers::Counter_int); sizeof(_cable_::wrappers::Counter_float); } #endif