blob: 8105003333f7035ecba96f1a2810e3e06d6470ca [file] [log] [blame]
##
## Licensed to the Apache Software Foundation (ASF) under one
## or more contributor license agreements. See the NOTICE file
## distributed with this work for additional information
## regarding copyright ownership. The ASF licenses this file
## to you under the Apache License, Version 2.0 (the
## "License"); you may not use this file except in compliance
## with the License. You may obtain a copy of the License at
##
## http://www.apache.org/licenses/LICENSE-2.0
##
## Unless required by applicable law or agreed to in writing,
## software distributed under the License is distributed on an
## "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
## KIND, either express or implied. See the License for the
## specific language governing permissions and limitations
## under the License.
##
// This file automatically generated by:
// $version
// $now
// This file is automatically created and should not be edited!
#set($i = $intf.name())
#set($intfname = "$i$suffix")
#set($clname = "Stub$intfname")
#ifndef __$helper.getStubName($intf, $mc).toUpperCase()_H__
\#define __$helper.getStubName($intf, $mc).toUpperCase()_H__
\#include "$inc"
#if($hasBaseClass)
\#include "Stub${i}.h"
#end
\#include "support/EtchDeliveryService.h"
#if(!$hasBaseClass)
\#include "support/EtchStubBase.h"
#end
\#include "ValueFactory${i}.h"
\#include "support/EtchStubHelper.h"
using namespace $namespace;
#foreach( $mthd in $intf.iterator() )
#if ($mthd.isMsgDir($mc))
#if (!$mthd.isHidden())
#set( $notEmpty = true)
class Run${mthd.vname($helper)}
: public EtchStubHelper<$i$suffix>
{
public:
status_t run(EtchStubBase<$i$suffix>* _ref, EtchDeliveryService *_svc, $i$suffix *_obj, capu::SmartPointer<EtchWho> _sender, capu::SmartPointer<EtchMessage> _msg )
{
status_t status = ETCH_OK;
#if (!$mthd.isOneway())
capu::SmartPointer<EtchMessage> _rmsg;
status = _msg->createReplyMessage(_rmsg);
if(status != ETCH_OK) {
// TODO log error
// TODO set exception
return ETCH_ERROR;
}
#end
// do stub call
#set($count = 0)
#foreach($param in $mthd.iterator())
#set($count = $count + 1)
EtchObjectPtr obj$count;
_msg->get(ValueFactory$i::$param.vname($helper)(), &obj$count);
$helper.getEtchTypeName($param.type(), true) val$count = capu::smartpointer_cast<$helper.getEtchTypeName($param.type(), false)>(obj$count);
#end
$intfname::$mthd.name()AsyncResultPtr ar;
#set($sep = "")
#set($count = 0)
ar = _obj->$mthd.name()(#foreach($param in $mthd.iterator())#if($mthd.hasAuth())${sep}$param.name()#else#set($count = $count + 1)${sep}val$count#end#set($sep = ", ")#end);
// create result message
#if($mthd.hasReturn())
if(ar->hasResult()) {
_rmsg->put(ValueFactory$i::_mf_result(), ar->getResult());
} else
#end
if(ar->hasException()) {
_ref->sessionNotify(ar->getException());
#if ($mthd.isOneway())
EtchMessagePtr _rmsg;
_msg->createReplyMessage( _msg->getValueFactory()->get_mt__exception(), _rmsg );
#end
_rmsg->put( ValueFactory$i::_mf_result(), ar->getException() );
#if ($mthd.isOneway())
// transport result message
status = _svc->transportMessage( _sender, _rmsg);
#end
}
#if (!$mthd.isOneway())
// transport result message
status = _svc->transportMessage( _sender, _rmsg);
#end
return status;
}
};
#end
#end
#end
namespace $namespace {
#if ($hasBaseClass)
/**
* Message to call translator for $i$suffix.
*/
class Stub$i$suffix : public Stub$i<$i$suffix>
#set( $T = "$i$suffix" )
#else
/**
* Message to call translator for $i$suffix.
* @param <T> $i$suffix or a subclass thereof.
*/
template<typename T>
class Stub$i$suffix : public EtchStubBase<T>
#set( $T = "T" )
#end
{
/**
* Stub for $i$suffix.
* @param svc the delivery service.
* @param obj the implementation of $i$suffix responsive to requests.
* @param free thread pool used to run AsyncMode.FREE methods.
* @param queued thread pool used to run AsyncMode.QUEUED methods.
*/
public:
#if(!$hasBaseClass)
Stub$i$suffix( EtchDeliveryService *svc, $T *obj, EtchQueuedPool* queued, EtchFreePool* free)
: EtchStubBase<T>(svc, obj, queued, free)
#else
Stub$i$suffix( EtchDeliveryService *svc, $T *obj, EtchQueuedPool* queued, EtchFreePool* free)
: Stub$i<$i$suffix>(svc, obj, queued, free)
#end
{
}
virtual ~Stub$i$suffix() {}
static void init()
{
// nothing to do.
}
##if($notEmpty)
/*
* Static Initialization-Helper
*/
private:
friend class ValueFactory${i};
static void __INIT()
{
#foreach( $mthd in $intf.iterator() )
#if ($mthd.isMsgDir($mc))
#if (!$mthd.isHidden())
ValueFactory$i::${mthd.vname( $helper )}->setStubHelper(new Run${mthd.vname($helper)}());
#end
#end
#if( $n.isMixin() )
#set( $m = $n.getModule() )
#set( $z = $m.iterator().next() )
${m.name()}::Stub${z.name()}${suffix}::init();
#end
#end
}
##end
};
}
#endif /* __$helper.getStubName($intf, $mc).toUpperCase()_H__ */