libcpp4ec
C++ for EtherCat Library
 All Classes Functions Variables Typedefs Enumerations Enumerator
EcSlaveFactory.h
1 /***************************************************************************
2  tag: Ruben Smits Tue Nov 16 09:26:15 CET 2010 soem_driver_factory.cpp
3 
4  soem_driver_factory.h - description
5  -------------------
6  begin : Tue November 16 2010
7  copyright : (C) 2010 Ruben Smits
8  email : first.last@mech.kuleuven.be
9 
10  ***************************************************************************
11  * This library is free software; you can redistribute it and/or *
12  * modify it under the terms of the GNU Lesser General Public *
13  * License as published by the Free Software Foundation; either *
14  * version 2.1 of the License, or (at your option) any later version. *
15  * *
16  * This library is distributed in the hope that it will be useful, *
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
19  * Lesser General Public License for more details. *
20  * *
21  * You should have received a copy of the GNU Lesser General Public *
22  * License along with this library; if not, write to the Free Software *
23  * Foundation, Inc., 59 Temple Place, *
24  * Suite 330, Boston, MA 02111-1307 USA *
25  * *
26  ***************************************************************************/
27 
28 #ifndef ECSLAVEFACTORY_H
29 #define ECSLAVEFACTORY_H
30 
31 #include <map>
32 #include <string>
33 #include "EcSlave.h"
34 
35 namespace cpp4ec
36 {
43 {
44 public:
49  {
50  static EcSlaveFactory soem_driver_factory;
51  return soem_driver_factory;
52  }
53 
57  typedef EcSlave* (*CreateDriverCallBack)(ec_slavet*);
58 
59 
63  bool registerDriver(std::string name, CreateDriverCallBack createFn);
64 
68  EcSlave* createDriver(ec_slavet* mem_loc);
69 
74 
75 private:
76  typedef std::map<std::string, CreateDriverCallBack> FactoryMap;
77  FactoryMap m_factory_map;
78 
80  {
81  }
82  ;
84  EcSlaveFactory& operator=(const EcSlaveFactory&);
86  {
87  }
88  ;
89 };
90 }
91 #endif
Class EcSlave.
Definition: EcSlave.h:53
bool registerDriver(std::string name, CreateDriverCallBack createFn)
Register the driver.
Definition: EcSlaveFactory.cpp:45
static EcSlaveFactory & Instance()
Makes an instance of the class.
Definition: EcSlaveFactory.h:48
EcSlave * createDriver(ec_slavet *mem_loc)
Create a driver.
Definition: EcSlaveFactory.cpp:53
Class EcSlaveFactory.
Definition: EcSlaveFactory.h:42
EcSlave *(* CreateDriverCallBack)(ec_slavet *)
A callback function.
Definition: EcSlaveFactory.h:57
Definition: EcMaster.h:37
void displayAvailableDrivers()
Display the drivers.
Definition: EcSlaveFactory.cpp:64