summaryrefslogtreecommitdiff
path: root/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/custom_vehicle_data_manager_impl.h
blob: 701bb1ba744976d66c920d8995cb132c8848f945 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_VEHICLE_DATA_VALIDATION_MANAGER_IMPL_H
#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_VEHICLE_DATA_VALIDATION_MANAGER_IMPL_H

#include <boost/optional.hpp>

#include "smart_objects/smart_object.h"
#include "vehicle_info_plugin/custom_vehicle_data_manager.h"

namespace rpc {
namespace policy_table_interface_base {
class VehicleDataItem;
}
}  // namespace rpc

namespace policy {
class VehicleDataItemProvider;
}

namespace vehicle_info_plugin {
namespace policy_table = rpc::policy_table_interface_base;
namespace plugin_manager = application_manager::plugin_manager;

typedef boost::optional<const policy_table::VehicleDataItem> OptionalDataItem;
typedef std::set<std::string> VehicleInfoSubscriptions;

class CustomVehicleDataManagerImpl : public CustomVehicleDataManager {
 public:
  CustomVehicleDataManagerImpl(
      policy::VehicleDataItemProvider& vehicle_data_provider,
      application_manager::rpc_service::RPCService& rpc_service);

  virtual smart_objects::SmartObject CreateHMIMessageParams(
      const std::set<std::string>& item_names) OVERRIDE;

  std::string GetVehicleDataItemType(
      const std::string& vehicle_data_item_name) const OVERRIDE;

  virtual void CreateMobileMessageParams(
      smart_objects::SmartObject& msg_params) OVERRIDE;

  void OnPolicyEvent(plugin_manager::PolicyEvent policy_event) OVERRIDE;

  bool IsValidCustomVehicleDataName(const std::string& name) const OVERRIDE;

 private:
  class RPCParams {
   public:
    RPCParams() {}
    ~RPCParams() {}

    void addBoolParam(
        const std::pair<std::string, smart_objects::SMember>& param) {
      rpc_params_bool_.insert(param);
    }
    void addVDRParam(
        const std::pair<std::string, smart_objects::SMember>& param) {
      rpc_params_vdr_.insert(param);
    }
    void addParam(const std::pair<std::string, smart_objects::SMember>& param) {
      rpc_params_.insert(param);
    }

    const std::map<std::string, smart_objects::SMember>& getBoolParams() {
      return rpc_params_bool_;
    }
    const std::map<std::string, smart_objects::SMember>& getVDRParams() {
      return rpc_params_vdr_;
    }
    const std::map<std::string, smart_objects::SMember>& getParams() {
      return rpc_params_;
    }

   private:
    std::map<std::string, smart_objects::SMember> rpc_params_bool_;
    std::map<std::string, smart_objects::SMember> rpc_params_vdr_;
    std::map<std::string, smart_objects::SMember> rpc_params_;
  };

  /**
   * @brief Updates vehicle data schemas according to policy update.
   */
  void UpdateVehicleDataItems();

  const OptionalDataItem FindSchemaByNameNonRecursive(
      const std::string& name) const;
  const OptionalDataItem FindSchemaByKeyNonRecursive(
      const std::string& key) const;
  const OptionalDataItem FindSchemaByNameRecursive(
      const std::string& name) const;
  const OptionalDataItem FindSchemaByKeyRecursive(
      const std::string& name) const;

  policy::VehicleDataItemProvider& vehicle_data_provider_;
  application_manager::rpc_service::RPCService& rpc_service_;
};

}  // namespace vehicle_info_plugin

#endif  // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_VEHICLE_DATA_VALIDATION_MANAGER_IMPL_H