and give the interface you
* want to implement dynamically as argument. Suppose your idl file looks
* like
*
*
* interface A { void a(); };
* interface B : A { void b(); };
*
*
* And you want to implement interface A "classic" (i.e. with mcopidl generated
* virtual void a()) and interface B "dynamic", you would do
*
*
* typedef Arts::DynamicSkeleton A_dskel; // convenient with typedef
*
* class B_impl : public A_dskel {
* public:
* B_impl() : A_dskel("B") { // we dynamically implement the B interface
* }
* void a() { // through A_skel
* arts_info("a called");
* }
* void process(long methodID, Arts::Buffer *request, Arts::Buffer *result)
* {
* const Arts::MethodDef& methodDef = getMethodDef(methodID);
*
* if(methodDef.name == "b")
* arts_info("b called!");
* else
* arts_fatal("Unknown method '%s' called");
* }
* };
*
*/
template
class DynamicSkeleton : virtual public Parent_skel, public DynamicSkeletonBase
{
public:
/**
* constructor
*/
DynamicSkeleton(const std::string& interface)
{
_dsInit(this, interface, Parent_skel::_interfaceNameSkel());
}
/**
* getMethodDef returns a MethodDef structure for a given methodID - it
* is quite useful if you implement process
*
*
* void process(long methodID, Arts::Buffer *request, Arts::Buffer *result)
* {
* const Arts::MethodDef& methodDef = getMethodDef(methodID);
*
* if(methodDef.name == "hello") // the method named hello was called
* printf("Hello!\n");
* else // method with other name was called
* arts_fatal("Method '%s' not implemented",methodDef.name.c_str());
* }
*
*/
const MethodDef& getMethodDef(long methodID) {
return this->_dsGetMethodDef(methodID);
}
/*-- reimplemented from Arts::Object_skel: --*/
std::string _interfaceName() {
return _dsInterfaceName();
}
bool _isCompatibleWith(const std::string& interfacename) {
if(_dsIsCompatibleWith(interfacename)) return true;
return Parent_skel::_isCompatibleWith(interfacename);
}
void _buildMethodTable() {
Parent_skel::_buildMethodTable();
_dsBuildMethodTable();
}
};
}
#endif /* ARTS_MCOP_DYNAMICSKELETON_H */