• Skip to main content
  • Skip to header right navigation
  • Skip to site footer
CDP Studio logo

CDP Studio

The no-code and full-code software development tool for distributed control systems and HMI

  • Doc
  • Why CDP
    • Software developers
    • Automation engineers
    • Managers
  • Products
    • Automation Designer
    • HMI Designer
    • Maritime HMIs
  • Services
  • Use cases
  • Pricing
  • Try CDP

CDP Studio Documentation

  • Framework - CDP2SQL
  • EventQuery
  • 5.0.0

EventQuery Class

(LogManager::EventQuery)

The EventQuery class contains the arguments for querying events from the database using LogReader. More...

Header: #include <EventQuery>
  • List of all members, including inherited members

Public Types

class Condition
enum Flags { None, NewestFirst, TimeRangeBeginExclusive, TimeRangeEndExclusive, UseLogstampForTimeRange }
enum MatchType { Exact, Wildcard }

Public Functions

EventQuery &AddDataCondition(const std::string &key, std::string value, MatchType type = Exact)
EventQuery &AddFlag(EventQuery::Flags flag)
EventQuery &AddSenderCondition(std::string value, MatchType type = Exact)
std::optional<unsigned> GetCodeMask() const
const std::map<std::string, std::vector<Condition> > &GetDataConditions() const
Flags GetFlags() const
std::optional<unsigned> GetLimit() const
std::optional<unsigned> GetOffset() const
const std::vector<Condition> &GetSenderConditions() const
std::optional<double> GetTimeRangeBegin() const
std::optional<double> GetTimeRangeEnd() const
bool HasConditions() const
bool HasFlag(Flags flag) const
EventQuery &RemoveFlag(Flags flag)
EventQuery &SetCodeMask(std::optional<unsigned int> codeMask)
EventQuery &SetFlags(Flags flags)
EventQuery &SetLimit(std::optional<unsigned int> limit)
EventQuery &SetOffset(std::optional<unsigned int> offset)
EventQuery &SetTimeRangeBegin(std::optional<double> timeRangeBegin)
EventQuery &SetTimeRangeEnd(std::optional<double> timeRangeEnd)

Detailed Description

The EventQuery class contains the arguments for querying events from the database using LogReader.

Usage

Create the query object and set the desired parameters. Then pass it to LogReader::ReadEvents().

Example

EventQuery query;
query.SetTimeRangeBegin(1234567890)
    .SetTimeRangeEnd(1234567891)
    .SetCodeMask(0x00000001)
    .SetLimit(100)
    .SetOffset(0)
    .AddFlag(EventQuery::NewestFirst)
    .AddSenderCondition("sender", EventQuery::Wildcard)
    .AddDataCondition("key", "value", EventQuery::Exact);
auto result = logReader->ReadEvents(query);

All arguments are optional. An empty query will return all events in the database.

See also LogReader::ReadEvents() and Event::code.

Member Type Documentation

enum EventQuery::Flags

Flags used to control the query.

ConstantValueDescription
LogManager::EventQuery::None0No flags.
LogManager::EventQuery::NewestFirst1Return newest events first.
LogManager::EventQuery::TimeRangeBeginExclusive2Use > instead of >= when comparing timeRangeBegin.
LogManager::EventQuery::TimeRangeEndExclusive4Use < instead of <= when comparing timeRangeEnd.
LogManager::EventQuery::UseLogstampForTimeRange8Use Event::logstampSec instead of timestampSec for timeRangeBegin and timeRangeEnd.

enum EventQuery::MatchType

The type of match to use when comparing strings.

ConstantValueDescription
LogManager::EventQuery::Exact0The string must match exactly.
LogManager::EventQuery::Wildcard1The string may contain wildcards.

Member Function Documentation

EventQuery &EventQuery::AddDataCondition(const std::string &key, std::string value, MatchType type = Exact)

Adds a event data condition to the query.

EventQuery &EventQuery::AddFlag(EventQuery::Flags flag)

Adds the given flag to the query.

EventQuery &EventQuery::AddSenderCondition(std::string value, MatchType type = Exact)

Adds a event sender condition to the query.

std::optional<unsigned> EventQuery::GetCodeMask() const

Returns only event codes allowed by the bitmask.

const std::map<std::string, std::vector<Condition> > &EventQuery::GetDataConditions() const

Returns the list of event data conditions.

Flags EventQuery::GetFlags() const

Returns the flags set to the query.

std::optional<unsigned> EventQuery::GetLimit() const

Returns the maximum number of events the query should return. Same as SQL LIMIT.

std::optional<unsigned> EventQuery::GetOffset() const

Returns the offset of the query. Same as SQL OFFSET. Use together with limit to return data in chuncks or pages.

const std::vector<Condition> &EventQuery::GetSenderConditions() const

Returns the list of event sender conditions.

std::optional<double> EventQuery::GetTimeRangeBegin() const

Returns the lower bound of the x-axis (timestamp). When empty, query start from the beginning of the log.

std::optional<double> EventQuery::GetTimeRangeEnd() const

Returns the upper bound of the x-axis (timestamp). When empty, queries until the end of the log.

bool EventQuery::HasConditions() const

Returns if the query has any conditions set.

bool EventQuery::HasFlag(Flags flag) const

Returns if the query has the given flag set.

EventQuery &EventQuery::RemoveFlag(Flags flag)

Removes the given flag from the query.

EventQuery &EventQuery::SetCodeMask(std::optional<unsigned int> codeMask)

Sets only event codes allowed by the bitmask. Useful for example to filter out reprise events.

EventQuery &EventQuery::SetFlags(Flags flags)

Sets the flags to the query.

EventQuery &EventQuery::SetLimit(std::optional<unsigned int> limit)

Sets the maximum number of events the query should return. Same as SQL LIMIT.

EventQuery &EventQuery::SetOffset(std::optional<unsigned int> offset)

Sets the offset of the query. Same as SQL OFFSET. Use together with limit to return data in chuncks or pages.

EventQuery &EventQuery::SetTimeRangeBegin(std::optional<double> timeRangeBegin)

Sets the lower bound of the timestampSec. When empty, query start from the beginning of the log.

EventQuery &EventQuery::SetTimeRangeEnd(std::optional<double> timeRangeEnd)

Sets the upper bound of the timestampSec. When empty, queries until the end of the log.

The content of this document is confidential information not to be published without the consent of CDP Technologies AS.

CDP Technologies AS, www.cdpstudio.com

Get started with CDP Studio today

Let us help you take your great ideas and turn them into the products your customer will love.

Try CDP Studio for free
Why CDP Studio?

CDP Technologies AS
Hundsværgata 8,
P.O. Box 144
6001 Ålesund, Norway

Tel: +47 990 80 900
E-mail: info@cdptech.com

Company

About CDP

Contact us

Services

Partners

Blog

Developers

Get started

User manuals

Support

Document download

Release notes

My account

Follow CDP

  • LinkedIn
  • YouTube
  • GitHub

© Copyright 2025 CDP Technologies. Privacy and cookie policy.

Return to top