summaryrefslogtreecommitdiff
path: root/includes/dynamic_depth/container.h
blob: 73ba1d74497c2225adfe39fb77e7214236f327de (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
#ifndef DYNAMIC_DEPTH_INCLUDES_DYNAMIC_DEPTH_CONTAINER_H_  // NOLINT
#define DYNAMIC_DEPTH_INCLUDES_DYNAMIC_DEPTH_CONTAINER_H_  // NOLINT

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

#include "dynamic_depth/element.h"
#include "dynamic_depth/item.h"

namespace dynamic_depth {

// A Container that holds a directory / array of file Item elementss. Files
// at the end of the image appear in the same sequential order as the Item
// elements held in an instance of this object.
class Container : public Element {
 public:
  void GetNamespaces(
      std::unordered_map<string, string>* ns_name_href_map) override;

  bool Serialize(
      ::dynamic_depth::xmpmeta::xml::Serializer* serializer) const override;

  // Creates this object from the given items. Returns null if the list is
  // empty. If creation succeeds, ownership of the Item objects are transferred
  // to the resulting Container object. The vector of Item objects will be
  // cleared.
  static std::unique_ptr<Container> FromItems(
      std::vector<std::unique_ptr<Item>>* items);

  // Returns the deserialized item elements, null if parsing failed for all
  // items.
  static std::unique_ptr<Container> FromDeserializer(
      const ::dynamic_depth::xmpmeta::xml::Deserializer& parent_deserializer);

  // Returns the list of cameras.
  const std::vector<const Item*> GetItems() const;

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

 private:
  Container();

  std::vector<std::unique_ptr<Item>> items_;
};

}  // namespace dynamic_depth

#endif // DYNAMIC_DEPTH_INCLUDES_DYNAMIC_DEPTH_CONTAINER_H_  // NOLINT