summaryrefslogtreecommitdiff
path: root/includes/dynamic_depth/vendor_info.h
blob: ba8ca48a530743e3aae3300101766049a8d44589 (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
#ifndef DYNAMIC_DEPTH_INCLUDES_DYNAMIC_DEPTH_VENDOR_INFO_H_  // NOLINT
#define DYNAMIC_DEPTH_INCLUDES_DYNAMIC_DEPTH_VENDOR_INFO_H_  // NOLINT

#include <memory>
#include <string>
#include <unordered_map>

#include "dynamic_depth/element.h"
#include "xmpmeta/xml/deserializer.h"
#include "xmpmeta/xml/serializer.h"

namespace photos_editing_formats {
namespace dynamic_depth {

/**
 * A VendorInfo element for a Dynamic Depth device.
 */
class VendorInfo : public Element {
 public:
  // Appends child elements' namespaces' and their respective hrefs to the
  // given collection, and any parent nodes' names to prefix_names.
  // Key: Name of the namespace.
  // Value: Full namespace URL.
  // Example: ("VendorInfo", "http://ns.google.com/photos/dd/1.0/vendorinfo/")
  void GetNamespaces(
      std::unordered_map<string, string>* ns_name_href_map) override;

  // Serializes this object.
  bool Serialize(xml::Serializer* serializer) const override;

  // Creates an VendorInfo from the given fields. Returns null if
  // any of the required fields is empty (see fields below).
  // Manufacturer is the manufacturer of the element that created the content.
  // Model is the model of the element that created the content.
  // Notes is general comments.
  static std::unique_ptr<VendorInfo> FromData(const string& manufacturer,
                                              const string& model,
                                              const string& notes);

  // Returns the deserialized VendorInfo; null if parsing fails.
  static std::unique_ptr<VendorInfo> FromDeserializer(
      const xml::Deserializer& parent_deserializer,
      const string& namespace_str);

  // Returns the Manufacturer.
  const string& GetManufacturer() const;

  // Returns the Model.
  const string& GetModel() const;

  // Returns the Notes.
  const string& GetNotes() const;

  // Disallow copying.
  VendorInfo(const VendorInfo&) = delete;
  void operator=(const VendorInfo&) = delete;

 private:
  VendorInfo();

  bool ParseFields(const xml::Deserializer& deserializer);

  // Required field.
  string manufacturer_;  // The manufacturer.

  // Optional fields.
  string model_;  // The model.
  string notes_;  // The notes.
};

}  // namespace dynamic_depth
}  // namespace photos_editing_formats

#endif // DYNAMIC_DEPTH_INCLUDES_DYNAMIC_DEPTH_VENDOR_INFO_H_  // NOLINT