Skip to content

Commit 4e1f93f

Browse files
jmirabelnim65s
authored andcommitted
Clean class Flags.
1 parent 78ee4f1 commit 4e1f93f

File tree

4 files changed

+72
-400
lines changed

4 files changed

+72
-400
lines changed

include/sot/core/flags.hh

Lines changed: 7 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -31,59 +31,37 @@ namespace sot {
3131

3232
class SOT_CORE_EXPORT Flags {
3333
protected:
34-
std::vector<char> flags;
35-
bool reverse;
36-
37-
char operator[](const unsigned int &i) const;
34+
std::vector<bool> flags;
35+
bool outOfRangeFlag;
3836

3937
public:
4038
Flags(const bool &b = false);
41-
Flags(const char &c);
42-
Flags(const int &c4);
39+
Flags(const char *flags);
40+
Flags(std::vector<bool> &&flags);
4341

44-
void add(const char &c);
45-
void add(const int &c4);
42+
void add(const bool &b);
4643

4744
Flags operator!(void) const;
4845
SOT_CORE_EXPORT friend Flags operator&(const Flags &f1, const Flags &f2);
4946
SOT_CORE_EXPORT friend Flags operator|(const Flags &f1, const Flags &f2);
5047
Flags &operator&=(const Flags &f2);
5148
Flags &operator|=(const Flags &f2);
5249

53-
SOT_CORE_EXPORT friend Flags operator&(const Flags &f1, const bool &b);
54-
SOT_CORE_EXPORT friend Flags operator|(const Flags &f1, const bool &b);
55-
Flags &operator&=(const bool &b);
56-
Flags &operator|=(const bool &b);
57-
5850
SOT_CORE_EXPORT friend std::ostream &operator<<(std::ostream &os,
5951
const Flags &fl);
60-
SOT_CORE_EXPORT friend char operator>>(const Flags &flags, const int &i);
6152
SOT_CORE_EXPORT friend std::istream &operator>>(std::istream &is, Flags &fl);
6253
bool operator()(const int &i) const;
6354

6455
operator bool(void) const;
6556

6657
void unset(const unsigned int &i);
6758
void set(const unsigned int &i);
68-
69-
public: /* Selec "matlab-style" : 1:15, 1:, :45 ... */
70-
static void readIndexMatlab(std::istream &iss, unsigned int &indexStart,
71-
unsigned int &indexEnd, bool &unspecifiedEnd);
72-
static Flags readIndexMatlab(std::istream &iss);
7359
};
7460

75-
SOT_CORE_EXPORT extern const Flags FLAG_LINE_1;
76-
SOT_CORE_EXPORT extern const Flags FLAG_LINE_2;
77-
SOT_CORE_EXPORT extern const Flags FLAG_LINE_3;
78-
SOT_CORE_EXPORT extern const Flags FLAG_LINE_4;
79-
SOT_CORE_EXPORT extern const Flags FLAG_LINE_5;
80-
SOT_CORE_EXPORT extern const Flags FLAG_LINE_6;
81-
SOT_CORE_EXPORT extern const Flags FLAG_LINE_7;
82-
SOT_CORE_EXPORT extern const Flags FLAG_LINE_8;
83-
8461
} // namespace sot
8562

86-
template <> struct signal_io<sot::Flags> : signal_io_unimplemented<sot::Flags> {};
63+
template <>
64+
struct signal_io<sot::Flags> : signal_io_unimplemented<sot::Flags> {};
8765
} // namespace dynamicgraph
8866

8967
#endif /* #ifndef __SOT_FLAGS_H */

src/python-module.cc

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,18 +48,17 @@ BOOST_PYTHON_MODULE(wrap)
4848
;
4949

5050
using dgs::Flags;
51-
bp::class_<Flags>("Flags", bp::init<const bool&>())
52-
.def(bp::init<const char&>())
53-
.def(bp::init<const int &>())
54-
.def("add", static_cast<void(Flags::*)(const char&)>(&Flags::add))
55-
.def("add", static_cast<void(Flags::*)(const int &)>(&Flags::add))
51+
bp::class_<Flags>("Flags", bp::init<>())
52+
.def(bp::init<const char*>())
53+
//TODO .def(bp::init<std::vector<bool>&& >())
54+
.def("add", &Flags::add)
5655
.def("set", &Flags::set)
5756
.def("unset", &Flags::unset)
5857

59-
.def(bp::self & bool())
60-
.def(bp::self | bool())
61-
.def(bp::self &= bool())
62-
.def(bp::self |= bool())
58+
.def(bp::self & bp::self)
59+
.def(bp::self | bp::self)
60+
.def(bp::self &= bp::self)
61+
.def(bp::self |= bp::self)
6362

6463
.def("__call__", &Flags::operator())
6564
.def("__bool__", &Flags::operator bool)

0 commit comments

Comments
 (0)