projects
/
lttng-tools.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Tests: Introduce gen-ust-events-constructor test application
[lttng-tools.git]
/
src
/
bin
/
lttng
/
utils.hpp
diff --git
a/src/bin/lttng/utils.hpp
b/src/bin/lttng/utils.hpp
index c3b442056cc1ecc6d88d518089c3168ea00679e0..262775d1d6bf0513e75f83c1ff0a939c68266b7d 100644
(file)
--- a/
src/bin/lttng/utils.hpp
+++ b/
src/bin/lttng/utils.hpp
@@
-26,13
+26,19
@@
extern pid_t sessiond_pid;
struct cmd_struct;
struct session_spec {
struct cmd_struct;
struct session_spec {
- enum type {
+ enum
class
type {
NAME,
GLOB_PATTERN,
ALL,
};
NAME,
GLOB_PATTERN,
ALL,
};
- type type;
+ explicit session_spec(type spec_type, const char *name_or_pattern = nullptr) noexcept :
+ type_(spec_type), value(name_or_pattern)
+ {
+ }
+
+ /* Disambiguate type enum from the member for buggy g++ versions. */
+ type type_;
const char *value;
};
const char *value;
};
@@
-40,56
+46,62
@@
struct session_spec {
* We don't use a std::vector here because it would make a copy of the C array.
*/
class session_list {
* We don't use a std::vector here because it would make a copy of the C array.
*/
class session_list {
- class iterator : public std::iterator<std::random_access_iterator_tag, std::size_t> {
+ template <typename ContainerType, typename DereferenceReturnType>
+ class _iterator
+ : public std::iterator<std::random_access_iterator_tag, std::size_t> {
public:
public:
- explicit iterator(session_list& list, std::size_t k) : _list(list), _index(k)
+ explicit _iterator(ContainerType& list, std::size_t k) :
+ _list(list), _index(k)
{
}
{
}
- iterator& operator++() noexcept
+
_
iterator& operator++() noexcept
{
++_index;
return *this;
}
{
++_index;
return *this;
}
- iterator& operator--() noexcept
+
_
iterator& operator--() noexcept
{
--_index;
return *this;
}
{
--_index;
return *this;
}
- iterator& operator++(int) noexcept
+
_
iterator& operator++(int) noexcept
{
_index++;
return *this;
}
{
_index++;
return *this;
}
- iterator& operator--(int) noexcept
+
_
iterator& operator--(int) noexcept
{
_index--;
return *this;
}
{
_index--;
return *this;
}
- bool operator==(iterator other) const noexcept
+ bool operator==(
_
iterator other) const noexcept
{
return _index == other._index;
}
{
return _index == other._index;
}
- bool operator!=(iterator other) const noexcept
+ bool operator!=(
_
iterator other) const noexcept
{
return !(*this == other);
}
{
return !(*this == other);
}
-
lttng_session
& operator*() const noexcept
+
DereferenceReturnType
& operator*() const noexcept
{
return _list[_index];
}
private:
{
return _list[_index];
}
private:
-
session_list
& _list;
+
ContainerType
& _list;
std::size_t _index;
};
std::size_t _index;
};
+ using iterator = _iterator<session_list, lttng_session>;
+ using const_iterator = _iterator<const session_list, const lttng_session>;
+
public:
session_list() : _sessions_count(0), _sessions(nullptr)
{
public:
session_list() : _sessions_count(0), _sessions(nullptr)
{
@@
-117,6
+129,16
@@
public:
return iterator(*this, _sessions_count);
}
return iterator(*this, _sessions_count);
}
+ const_iterator begin() const noexcept
+ {
+ return const_iterator(*this, 0);
+ }
+
+ const_iterator end() const noexcept
+ {
+ return const_iterator(*this, _sessions_count);
+ }
+
std::size_t size() const noexcept
{
return _sessions_count;
std::size_t size() const noexcept
{
return _sessions_count;
@@
-142,7
+164,7
@@
public:
private:
std::size_t _sessions_count;
std::unique_ptr<lttng_session,
private:
std::size_t _sessions_count;
std::unique_ptr<lttng_session,
- lttng::
details::create_unique_class<lttng_session, lttng::free>
>
+ lttng::
memory::create_deleter_class<lttng_session, lttng::free>::deleter
>
_sessions;
};
_sessions;
};
This page took
0.02466 seconds
and
4
git commands to generate.