blob: 0028c88bdbd0fc994f05d5a7f7d21b92711ce5af [file] [log] [blame]
Alex Vakulenkoaa3a5592014-08-07 07:24:06 -07001// Copyright 2014 The Chromium OS Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef BUFFET_COMMANDS_COMMAND_INSTANCE_H_
6#define BUFFET_COMMANDS_COMMAND_INSTANCE_H_
7
8#include <map>
9#include <memory>
10#include <string>
11
12#include <base/basictypes.h>
13
14#include "buffet/commands/prop_values.h"
15#include "buffet/commands/schema_utils.h"
16
17namespace buffet {
18
19class CommandInstance final {
20 public:
21 // Construct a command instance given the full command |name| which must
22 // be in format "<package_name>.<command_name>", a command |category| and
23 // a list of parameters and their values specified in |parameters|.
24 CommandInstance(const std::string& name, const std::string& category,
25 const native_types::Object& parameters);
26
27 // Returns the full name of the command.
28 const std::string& GetName() const { return name_; }
29 // Returns the command category.
30 const std::string& GetCategory() const { return category_; }
31 // Returns the command parameters and their values.
32 const native_types::Object& GetParameters() const { return parameters_; }
33 // Finds a command parameter value by parameter |name|. If the parameter
34 // with given name does not exist, returns null shared_ptr.
35 std::shared_ptr<const PropValue> FindParameter(const std::string& name) const;
36
37 private:
38 // Full command name as "<package_name>.<command_name>".
39 std::string name_;
40 // Command category. See comments for CommandDefinitions::LoadCommands for the
41 // detailed description of what command categories are and what they are used
42 // for.
43 std::string category_;
44 // Command parameters and their values.
45 native_types::Object parameters_;
46
47 DISALLOW_COPY_AND_ASSIGN(CommandInstance);
48};
49
50} // namespace buffet
51
52#endif // BUFFET_COMMANDS_COMMAND_INSTANCE_H_