Publishing R3
[platform/upstream/dldt.git] / inference-engine / thirdparty / ade / ade / source / metadata.cpp
1 // Copyright (C) 2018 Intel Corporation
2 //
3 // SPDX-License-Identifier: Apache-2.0
4 //
5
6 #include "metadata.hpp"
7
8 #include "util/assert.hpp"
9
10 namespace ade
11 {
12
13 Metadata::Metadata()
14 {
15
16 }
17
18 util::any& Metadata::operator[](const MetadataId& id)
19 {
20     ASSERT(nullptr != id);
21     return m_data[id];
22 }
23
24 bool Metadata::contains(const MetadataId& id) const
25 {
26     ASSERT(nullptr != id);
27     return m_data.end() != m_data.find(id);
28 }
29
30 void Metadata::erase(const MetadataId& id)
31 {
32     m_data.erase(id);
33 }
34
35 Metadata::MetadataRange Metadata::all()
36 {
37     return util::toRange(m_data);
38 }
39
40 Metadata::MetadataCRange Metadata::all() const
41 {
42     return util::toRange(m_data);
43 }
44
45 void Metadata::copyFrom(const Metadata& data)
46 {
47     m_data = data.m_data;
48 }
49
50 std::size_t Metadata::IdHash::operator()(const MetadataId& id) const
51 {
52     return std::hash<decltype(MetadataId::m_id)>()(id.m_id);
53 }
54
55 MetadataId::MetadataId(void* id):
56     m_id(id)
57 {
58     ASSERT(nullptr != m_id);
59 }
60
61 bool MetadataId::operator==(const MetadataId& other) const
62 {
63     return m_id == other.m_id;
64 }
65
66 bool MetadataId::operator!=(const MetadataId& other) const
67 {
68     return m_id != other.m_id;
69 }
70
71 bool MetadataId::isNull() const
72 {
73     return nullptr == m_id;
74 }
75
76 bool operator==(std::nullptr_t, const MetadataId& other)
77 {
78     return other.isNull();
79 }
80
81 bool operator==(const MetadataId& other, std::nullptr_t)
82 {
83     return other.isNull();
84 }
85
86 bool operator!=(std::nullptr_t, const MetadataId& other)
87 {
88     return !other.isNull();
89 }
90
91 bool operator!=(const MetadataId& other, std::nullptr_t)
92 {
93     return !other.isNull();
94 }
95
96 }