// Copyright 2014 The Chromium OS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef BUFFET_COMMANDS_COMMAND_DICTIONARY_H_
#define BUFFET_COMMANDS_COMMAND_DICTIONARY_H_

#include <map>
#include <memory>
#include <string>
#include <vector>

#include <base/basictypes.h>

#include "buffet/error.h"

namespace base {
class Value;
class DictionaryValue;
}  // namespace base

namespace buffet {

class CommandDefinition;

// CommandDictionary is a wrapper around a map of command name and the
// corresponding command definition schema. The command name (the key in
// the map) is a compound name in a form of "package_name.command_name",
// where "package_name" is a name of command package such as "base", "printers",
// and others. So the full command name could be "base.reboot", for example.
class CommandDictionary {
 public:
  CommandDictionary() = default;

  // Gets the list of names of commands that belong to the given category.
  std::vector<std::string> GetCommandNamesByCategory(
      const std::string& category) const;

  // Loads command definitions from a JSON object. This is done at the daemon
  // startup and whenever a device daemon decides to update its command list.
  // |json| is a JSON dictionary that describes the complete commands contained
  // in a particular |category|. Usually, |categories| are 1:1 with daemons on
  // a device. For instance, the power manager daemon might provide a category
  // "power_man" that provides the "base.reboot" and "base.shutdown" commands.
  // However, nothing prohibits a daemon providing commands in two categories.
  // When LoadCommands is called, all previous definitions of commands from the
  // same category are removed, effectively replacing all the commands in the
  // given category.
  // Optional |base_commands| parameter specifies the definition of standard
  // GCD commands for parameter schema validation. Can be set to nullptr if
  // no validation is needed.
  // Returns false on failure and |error| provides additional error information
  // when provided.
  bool LoadCommands(const base::DictionaryValue& json,
                    const std::string& category,
                    const CommandDictionary* base_commands, ErrorPtr* error);
  // Converts all the command definitions to a JSON object for CDD/Device
  // draft. |full_schema| specifies whether full command definitions must
  // be generated (true) for CDD or only overrides from the base schema (false).
  // Returns empty unique_ptr in case of an error and fills in the additional
  // error details in |error|.
  std::unique_ptr<base::DictionaryValue> GetCommandsAsJson(
      bool full_schema, ErrorPtr* error) const;
  // Returns the number of command definitions in the dictionary.
  size_t GetSize() const { return definitions_.size(); }
  // Checks if the dictionary has no command definitions.
  bool IsEmpty() const { return definitions_.empty(); }
  // Remove all the command definitions from the dictionary.
  void Clear();
  // Finds a definition for the given command.
  const CommandDefinition* FindCommand(const std::string& command_name) const;

 private:
  using CommandMap = std::map<std::string,
                              std::shared_ptr<const CommandDefinition>>;

  CommandMap definitions_;  // List of all available command definitions.
  DISALLOW_COPY_AND_ASSIGN(CommandDictionary);
};

}  // namespace buffet

#endif  // BUFFET_COMMANDS_COMMAND_DICTIONARY_H_
