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>
36 namespace AbstractRPCConnectionEvents
39 * Asynchronous call event
41 DECLARE_GENERIC_EVENT_1(AsyncCallEvent, RPCFunction)
44 * Connection closed event
46 DECLARE_GENERIC_EVENT_0(ConnectionClosedEvent)
49 * Connection broken event
51 DECLARE_GENERIC_EVENT_0(ConnectionBrokenEvent)
52 } // namespace AbstractRPCConnectionEvents
54 class AbstractRPCConnection
55 : public DPL::Event::EventSupport<AbstractRPCConnectionEvents::AsyncCallEvent>,
56 public DPL::Event::EventSupport<AbstractRPCConnectionEvents::ConnectionClosedEvent>,
57 public DPL::Event::EventSupport<AbstractRPCConnectionEvents::ConnectionBrokenEvent>
63 DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
64 DECLARE_EXCEPTION_TYPE(Base, AsyncCallFailed)
65 DECLARE_EXCEPTION_TYPE(Base, PingFailed)
69 virtual ~AbstractRPCConnection() {}
72 * Call asynchronously RPC function
74 * @param function COnstant reference to RPC function to call
77 virtual void AsyncCall(const RPCFunction &function) = 0;
81 * This will send a ping/pong packet over connection to ensure it is alive
82 * If any errors are to occur proper events will be emitted
86 virtual void Ping() = 0;
90 * Abstract connection ID used to represent connection being established
91 * or RPC server accepting connection
93 typedef void *AbstractRPCConnectionID;
98 #endif // DPL_ABSTRACT_RPC_CONNECTION_H