MIRA
CANManager.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012 MetraLabs GmbH (MLAB), GERMANY.
3  * All rights reserved.
4  * Contact: info@MetraLabs.com
5  *
6  * Commercial Usage:
7  * Licensees holding valid commercial licenses may use this file in
8  * accordance with the commercial license agreement provided with the
9  * software or, alternatively, in accordance with the terms contained in
10  * a written agreement between you and MetraLabs.
11  *
12  * GNU General Public License Usage:
13  * Alternatively, this file may be used under the terms of the GNU
14  * General Public License version 3.0 as published by the Free Software
15  * Foundation and appearing in the file LICENSE.GPL3 included in the
16  * packaging of this file. Please review the following information to
17  * ensure the GNU General Public License version 3.0 requirements will be
18  * met: http://www.gnu.org/copyleft/gpl.html.
19  * Alternatively you may (at your option) use any later version of the GNU
20  * General Public License if such license has been publicly approved by
21  * MetraLabs (or its successors, if any).
22  *
23  * IN NO EVENT SHALL "MLAB" BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
24  * SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE
25  * OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF "MLABS" HAS BEEN
26  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  *
28  * "MLAB" SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT
29  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
30  * A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN
31  * "AS IS" BASIS, AND "MLAB" HAS NO OBLIGATION TO PROVIDE MAINTENANCE,
32  * SUPPORT, UPDATES, ENHANCEMENTS OR MODIFICATIONS.
33  */
34 
43 #ifndef _MLAB_CANMANAGER_H_
44 #define _MLAB_CANMANAGER_H_
45 
46 #include <string>
47 #include <vector>
48 
49 #ifndef Q_MOC_RUN
50 #include <boost/thread/mutex.hpp>
51 #endif
52 
53 #include <utils/Singleton.h>
54 
55 #include <can/CANDefs.h>
56 #include <can/CANDriverInterface.h>
57 
58 namespace mira { namespace can {
59 
61 
65 class MLAB_CAN_EXPORT CANManager : public LazySingleton<CANManager>
66 {
67 
68 public:
71 
73  CANManager();
74 
76  virtual ~CANManager();
77 
79 
80 public:
83 
91  CANInterfacePtr requestBus(const std::string driver,
92  const std::string& deviceName,
93  CANBaudRate baudRate);
94 
96 
97 private:
98 
99  boost::mutex mMutex;
100  std::vector<CANDriverInterfacePtr> mEntries;
101 };
102 
104 
105 }} // namespaces
106 
107 #endif
CANBaudRate
An enum of the different CAN baud rates.
Definition: CANDefs.h:59
boost::shared_ptr< CANInterface > CANInterfacePtr
A shared pointer of the CANInterface.
Definition: CANInterface.h:224
A class for handling multiple access to the CAN bus.
Definition: CANManager.h:65
#define MLAB_CAN_EXPORT
Definition: CANExports.h:57
A common interface to the CAN bus.
Common CANbus definitions.