Fix for x86_64 build fail
[platform/upstream/connectedhomeip.git] / examples / chip-tool / commands / common / Commands.h
1 /*
2  *   Copyright (c) 2020 Project CHIP Authors
3  *   All rights reserved.
4  *
5  *   Licensed under the Apache License, Version 2.0 (the "License");
6  *   you may not use this file except in compliance with the License.
7  *   You may obtain a copy of the License at
8  *
9  *       http://www.apache.org/licenses/LICENSE-2.0
10  *
11  *   Unless required by applicable law or agreed to in writing, software
12  *   distributed under the License is distributed on an "AS IS" BASIS,
13  *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  *   See the License for the specific language governing permissions and
15  *   limitations under the License.
16  *
17  */
18
19 #pragma once
20
21 #include "../../config/PersistentStorage.h"
22 #include "Command.h"
23 #include <map>
24
25 class Commands
26 {
27 public:
28     using NodeId         = ::chip::NodeId;
29     using CommandsVector = ::std::vector<std::unique_ptr<Command>>;
30
31     void Register(const char * clusterName, commands_list commandsList);
32     int Run(NodeId localId, NodeId remoteId, int argc, char ** argv);
33
34 private:
35     CHIP_ERROR RunCommand(PersistentStorage & storage, NodeId localId, NodeId remoteId, int argc, char ** argv);
36     std::map<std::string, CommandsVector>::iterator GetCluster(std::string clusterName);
37     Command * GetCommand(CommandsVector & commands, std::string commandName);
38     Command * GetGlobalCommand(CommandsVector & commands, std::string commandName, std::string attributeName);
39     bool IsGlobalCommand(std::string commandName) const;
40
41     void ShowClusters(std::string executable);
42     void ShowCluster(std::string executable, std::string clusterName, CommandsVector & commands);
43     void ShowClusterAttributes(std::string executable, std::string clusterName, std::string commandName, CommandsVector & commands);
44     void ShowCommand(std::string executable, std::string clusterName, Command * command);
45
46     std::map<std::string, CommandsVector> mClusters;
47 };