2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 * @file abstract_rpc_connection.h
18 * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
20 * @brief This file is the header file for abstract RPC connection
22 #ifndef DPL_ABSTRACT_RPC_CONNECTION_H
23 #define DPL_ABSTRACT_RPC_CONNECTION_H
25 #include <dpl/rpc/rpc_function.h>
26 #include <dpl/exception.h>
27 #include <dpl/generic_event.h>
28 #include <dpl/event/event_support.h>
34 namespace AbstractRPCConnectionEvents {
36 * Asynchronous call event
38 DECLARE_GENERIC_EVENT_1(AsyncCallEvent, RPCFunction)
41 * Connection closed event
43 DECLARE_GENERIC_EVENT_0(ConnectionClosedEvent)
46 * Connection broken event
48 DECLARE_GENERIC_EVENT_0(ConnectionBrokenEvent)
49 } // namespace AbstractRPCConnectionEvents
51 class AbstractRPCConnection :
52 public DPL::Event::EventSupport<AbstractRPCConnectionEvents::AsyncCallEvent>,
53 public DPL::Event::EventSupport<AbstractRPCConnectionEvents::
54 ConnectionClosedEvent>,
55 public DPL::Event::EventSupport<AbstractRPCConnectionEvents::
56 ConnectionBrokenEvent>
62 DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
63 DECLARE_EXCEPTION_TYPE(Base, AsyncCallFailed)
64 DECLARE_EXCEPTION_TYPE(Base, PingFailed)
68 virtual ~AbstractRPCConnection() {}
71 * Call asynchronously RPC function
73 * @param function COnstant reference to RPC function to call
76 virtual void AsyncCall(const RPCFunction &function) = 0;
80 * This will send a ping/pong packet over connection to ensure it is alive
81 * If any errors are to occur proper events will be emitted
85 virtual void Ping() = 0;
89 * Abstract connection ID used to represent connection being established
90 * or RPC server accepting connection
92 typedef void *AbstractRPCConnectionID;
96 #endif // DPL_ABSTRACT_RPC_CONNECTION_H