Skip to content
Mario Bielert edited this page Jun 29, 2017 · 12 revisions

The cursor is kind of like an iterator known from the C++ standard library. It is used to transport data from async plugins to Score-P. In contrast to an iterator, the cursor takes care of memory handling for the user.

Usage

Suppose you have a Cursor c, then you iterate over your data and use the write() method of the Cursor to write each data point to it.

std::vector<std::pair<ticks, double>> my_data;

for (auto& data : my_data)
{
   // if you have a std::pair you can use the stream operator
   c << data;
   // else you just use write(timestamp, value)
   c.write(data.first, data.second);
}

Note:

The write() method of the cursor is overloaded in such way, that it distinguishes between signed and unsigned integers, and float and double values. However, you should absolutely make sure, that the value type of the metric matches with the type of the value, which is written to the cursor.

Methods

void resize(std::size_t new_size)

Resizes the underlaying vector to new_size.

After calling this function, the following is true:

new_size == size() and capacity() == size()

void write(chrono::ticks t, T v)

Writes (t,v) data point to the underlying data structure

Note:

In contrast to void store(chrono::ticks t, T v) it also checks, whether (t,v) is in the temporal range of the measurement and it calls void resize(std::size_t) if appropriate.

void write(std::pair<chrono::ticks, T> p)

Convenience method for void write(chrono::ticks t, T v) for pairs.

Cursor& operator<<(std::pair<chrono::ticks, T> p)

Convenience method for void write(chrono::ticks t, T v) for pairs.

void store(chrono::ticks t, T v)

Writes (t,v) datapoint unchecked to underlying data structure

std::size_t capacity()

Returns to current number of data points, the underlying data structure can hold in total.

std::size_t size()

Returns the amount of stored data points.

bool in_range(scorep::chrono::ticks t)

Checks whether the given time point in ticks is in the temporal range of the measurement

See also

Clone this wiki locally