• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2020 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef INCLUDE_PERFETTO_EXT_TRACE_PROCESSOR_IMPORTERS_MEMORY_TRACKER_MEMORY_ALLOCATOR_NODE_ID_H_
18 #define INCLUDE_PERFETTO_EXT_TRACE_PROCESSOR_IMPORTERS_MEMORY_TRACKER_MEMORY_ALLOCATOR_NODE_ID_H_
19 
20 #include <stdint.h>
21 
22 #include <string>
23 
24 #include "perfetto/base/export.h"
25 
26 namespace perfetto {
27 namespace trace_processor {
28 
29 class PERFETTO_EXPORT_COMPONENT MemoryAllocatorNodeId {
30  public:
31   MemoryAllocatorNodeId();
32   explicit MemoryAllocatorNodeId(uint64_t id);
33 
ToUint64()34   uint64_t ToUint64() const { return id_; }
35 
36   // Returns a (hex-encoded) string representation of the id.
37   std::string ToString() const;
38 
empty()39   bool empty() const { return id_ == 0u; }
40 
41   bool operator==(const MemoryAllocatorNodeId& other) const {
42     return id_ == other.id_;
43   }
44 
45   bool operator!=(const MemoryAllocatorNodeId& other) const {
46     return !(*this == other);
47   }
48 
49   bool operator<(const MemoryAllocatorNodeId& other) const {
50     return id_ < other.id_;
51   }
52 
53  private:
54   uint64_t id_;
55 
56   // Deliberately copy-able.
57 };
58 
59 }  // namespace trace_processor
60 }  // namespace perfetto
61 
62 #endif  // INCLUDE_PERFETTO_EXT_TRACE_PROCESSOR_IMPORTERS_MEMORY_TRACKER_MEMORY_ALLOCATOR_NODE_ID_H_
63