OpenZWave Library  1.4.164
CommandClasses.h
Go to the documentation of this file.
1 //-----------------------------------------------------------------------------
2 //
3 // CommandClasses.h
4 //
5 // Singleton holding methods to create each command class object
6 //
7 // Copyright (c) 2010 Mal Lansell <openzwave@lansell.org>
8 //
9 // SOFTWARE NOTICE AND LICENSE
10 //
11 // This file is part of OpenZWave.
12 //
13 // OpenZWave is free software: you can redistribute it and/or modify
14 // it under the terms of the GNU Lesser General Public License as published
15 // by the Free Software Foundation, either version 3 of the License,
16 // or (at your option) any later version.
17 //
18 // OpenZWave is distributed in the hope that it will be useful,
19 // but WITHOUT ANY WARRANTY; without even the implied warranty of
20 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 // GNU Lesser General Public License for more details.
22 //
23 // You should have received a copy of the GNU Lesser General Public License
24 // along with OpenZWave. If not, see <http://www.gnu.org/licenses/>.
25 //
26 //-----------------------------------------------------------------------------
27 
28 #ifndef _CommandClasses_H
29 #define _CommandClasses_H
30 
31 #include <string>
32 #include <map>
33 #include "Defs.h"
34 
35 namespace OpenZWave
36 {
37  class CommandClass;
38 
42  {
43  public:
44  typedef CommandClass* (*pfnCreateCommandClass_t)( uint32 const _homeId, uint8 const _nodeId );
45 
46  static void RegisterCommandClasses();
47  static CommandClass* CreateCommandClass( uint8 const _commandClassId, uint32 const _homeId, uint8 const _nodeId );
48 
49  static bool IsSupported( uint8 const _commandClassId );
50  static string GetName(uint8 const _commandClassId);
51  private:
53  CommandClasses( CommandClasses const& ); // prevent copy
54  CommandClasses& operator = ( CommandClasses const& ); // prevent assignment
55 
56  static CommandClasses& Get()
57  {
58  static CommandClasses instance;
59  return instance;
60  }
61 
62  void Register( uint8 const _commandClassId, string const& _commandClassName, pfnCreateCommandClass_t _create );
63  void ParseCommandClassOption( string const& _optionStr, bool const _include );
64  uint8 GetCommandClassId( string const& _name );
65 
66  pfnCreateCommandClass_t m_commandClassCreators[256];
67  map<string,uint8> m_namesToIDs;
68 
69  // m_supportedCommandClasses uses single bits to mark whether OpenZWave supports a command class
70  // Checking this is not the same as looking for non-NULL entried in m_commandClassCreators, since
71  // this may be modified by the program options --Include and --Ingnore to filter out support
72  // for unwanted command classes.
73  uint32 m_supportedCommandClasses[8];
74  };
75 
76 } // namespace OpenZWave
77 
78 
79 #endif
Manages a map of command classes supported by a specific Z-Wave node.
Definition: CommandClasses.h:41
Definition: Bitfield.h:34
Base class for all Z-Wave command classes.
Definition: CommandClass.h:46
CommandClass *(* pfnCreateCommandClass_t)(uint32 const _homeId, uint8 const _nodeId)
Definition: CommandClasses.h:44
static void RegisterCommandClasses()
Definition: CommandClasses.cpp:182
unsigned int uint32
Definition: Defs.h:80
static CommandClass * CreateCommandClass(uint8 const _commandClassId, uint32 const _homeId, uint8 const _nodeId)
Definition: CommandClasses.cpp:160
static bool IsSupported(uint8 const _commandClassId)
Definition: CommandClasses.cpp:119
static string GetName(uint8 const _commandClassId)
Definition: CommandClasses.cpp:126
unsigned char uint8
Definition: Defs.h:74