reverted varianttype
[profile/ivi/automotive-message-broker.git] / plugins / common / canadapter.h
1 /*
2 Copyright (C) 2012 Intel Corporation
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with this library; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
17 */
18
19 #ifndef CANADAPTER_H
20 #define CANADAPTER_H
21
22 /**
23  *  \addtogroup libcanbus
24  *  @{
25  */
26
27 #include <linux/can.h>
28
29 class CANObserver;
30
31 /**
32 * \brief Abstracts CAN hardware object representation.
33 * Has protected constructor.
34 * Instance of the object has to be done via CANAdapter#createCANAdapter method.
35 *
36 *       @code CANAdapter* pAdapter = CANAdapter::createCANAdapter(this); @endcode
37 *
38 * @class CANAdapter
39 */
40 class CANAdapter
41 {
42 public:
43     virtual ~CANAdapter();/*LCOV_EXCL_LINE*/
44     /**
45     * Creates and initializes CANAdapter instance
46     * @fn createCANAdapter
47     * @param observer @link CANObserver Observer @endlink that will receives CAN bus frames
48     * @return Pointer to CANAdapter instance
49     * @static
50     */
51     static CANAdapter* createCANAdapter(CANObserver& observer);
52     /**
53     * Starts listening to CAN bus on the specified interface
54     * @fn start
55     * @param name Name of the CAN bus interface
56     * @return True if no error occurs.
57     */
58     virtual bool start(const char* name) = 0;
59     /**
60     * Stops listening to CAN bus
61     * @fn stop
62     */
63     virtual void stop() = 0;
64     /**
65     * Sends CAN frame over the bus
66     * @fn sendFrame
67     * @param frame CAN frame to be sent
68     * @return True if frame was sent
69     */
70     virtual bool sendFrame(const can_frame& frame) = 0;
71
72 protected:
73     /**
74     * @param observer @link CANObserver Observer @endlink that will receives CAN bus frames
75     */
76     CANAdapter(CANObserver& observer);
77
78 protected:
79     /**
80     * #CANObserver instance reference
81     * @property mObserver
82     * @protected
83     */
84     CANObserver& mObserver;
85
86 };
87
88 #endif // CANADAPTER_H
89
90 /** @} */