Choreonoid  1.5
Selection.h
Go to the documentation of this file.
1 
5 #ifndef CNOID_UTIL_SELECTION_H
6 #define CNOID_UTIL_SELECTION_H
7 
8 #include <vector>
9 #include <string>
10 #include "exportdecl.h"
11 
12 namespace cnoid {
13 
15 {
16 public:
17  explicit Selection(const char* domainname = 0);
18 
19  explicit Selection(size_t size, const char* domainname = 0);
20 
21  int size() const {
22  return symbols_.size();
23  }
24 
25  operator bool() const {
26  return selectedIndex_ >= 0;
27  }
28 
29  void resize(int s);
30 
31  void clear();
32 
33  void setSymbol(int index, const std::string& symbol);
34 
35  Selection& operator<<(const std::string& symbol);
36 
37  std::string& symbol(int index) {
38  return symbols_[index];
39  }
40 
41  const std::string& symbol(int index) const {
42  return symbols_[index];
43  }
44 
45  int index(const std::string& symbol) const;
46 
47  const char* label(int index) const;
48 
49  bool select(int index);
50  bool selectIndex(int index);
51  bool select(const std::string& symbol);
52 
53  int selectedIndex() const {
54  return selectedIndex_;
55  }
56 
57  int which() const {
58  return selectedIndex_;
59  }
60 
61  bool is(int index) const {
62  return (index == selectedIndex_);
63  }
64 
65  const char* selectedSymbol() const;
66  const char* selectedLabel() const;
67 
68 private:
69  std::vector<std::string> symbols_;
70  int selectedIndex_;
71  const char* domainname_;
72 };
73 
74 }
75 
76 #endif
CNOID_EXPORT std::ostream & operator<<(std::ostream &os, const BoundingBox &bb)
Definition: BoundingBox.cpp:153
int selectedIndex() const
Definition: Selection.h:53
const std::string & symbol(int index) const
Definition: Selection.h:41
Definition: Selection.h:14
int size() const
Definition: Selection.h:21
std::string & symbol(int index)
Definition: Selection.h:37
bool is(int index) const
Definition: Selection.h:61
Defines the minimum processing for performing pasing file for STL.
Definition: AbstractSceneLoader.h:9
int which() const
Definition: Selection.h:57
#define CNOID_EXPORT
Definition: Util/exportdecl.h:37