Overte C++ Documentation
Selection.h
1 //
2 // Selection.h
3 // render/src/render
4 //
5 // Created by Sam Gateau on 4/4/2017.
6 // Copyright 2017 High Fidelity, Inc.
7 // Copyright 2024 Overte e.V.
8 //
9 // Distributed under the Apache License, Version 2.0.
10 // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
11 //
12 
13 #ifndef hifi_render_Selection_h
14 #define hifi_render_Selection_h
15 
16 #include "Item.h"
17 
18 namespace render {
19 
20  class Selection {
21  public:
22  using Name = std::string;
23 
24  ~Selection();
25  Selection();
26  Selection(const Selection& selection);
27  Selection& operator = (const Selection& selection);
28  Selection(Selection&& selection);
29  Selection& operator = (Selection&& selection);
30 
31  Selection(const Name& name, const ItemIDs& items);
32 
33  const Name& getName() const { return _name; }
34 
35  const ItemIDs& getItems() const { return _items; }
36 
37  bool isEmpty() const { return _items.empty(); }
38 
39  // Test if the ID is in the selection, return the index or -1 if not present
40  static const int NOT_FOUND{ -1 };
41 
42  void add(ItemID id) { _items.push_back(id); }
43  int find(ItemID id) const;
44  bool contains(ItemID id) const { return find(id) > NOT_FOUND; }
45 
46  protected:
47  Name _name;
48  ItemIDs _items;
49  };
50 
51  using SelectionMap = std::unordered_map<Selection::Name, Selection>;
52 
53 }
54 
55 #endif