Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add [[nodiscard]] to cpp #3279

Merged
merged 10 commits into from
Dec 17, 2024
28 changes: 14 additions & 14 deletions cpp/include/DataStorm/DataStorm.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,14 @@ namespace DataStorm
*
* @return The sample event.
*/
SampleEvent getEvent() const noexcept;
[[nodiscard]] SampleEvent getEvent() const noexcept;

/**
* The key of the sample.
*
* @return The sample key.
*/
const Key& getKey() const noexcept;
[[nodiscard]] const Key& getKey() const noexcept;

/**
* The value of the sample.
Expand All @@ -73,7 +73,7 @@ namespace DataStorm
*
* @return The sample value.
*/
const Value& getValue() const noexcept;
[[nodiscard]] const Value& getValue() const noexcept;

/**
* The update tag for the partial update.
Expand All @@ -82,7 +82,7 @@ namespace DataStorm
*
* @return The update tag.
*/
UpdateTag getUpdateTag() const noexcept;
[[nodiscard]] UpdateTag getUpdateTag() const noexcept;

/**
* The timestamp of the sample.
Expand All @@ -91,7 +91,7 @@ namespace DataStorm
*
* @return The timestamp.
*/
std::chrono::time_point<std::chrono::system_clock> getTimeStamp() const noexcept;
[[nodiscard]] std::chrono::time_point<std::chrono::system_clock> getTimeStamp() const noexcept;

/**
* The origin of the sample.
Expand All @@ -102,7 +102,7 @@ namespace DataStorm
*
* @return The origin of the sample.
*/
std::string getOrigin() const noexcept;
[[nodiscard]] std::string getOrigin() const noexcept;

/**
* Get the session identifier of the session that received this sample.
Expand All @@ -111,7 +111,7 @@ namespace DataStorm
*
* @return The session identifier.
*/
std::string getSession() const noexcept;
[[nodiscard]] std::string getSession() const noexcept;

/** @private */
Sample(const std::shared_ptr<DataStormI::Sample>&) noexcept;
Expand Down Expand Up @@ -228,7 +228,7 @@ namespace DataStorm
*
* @return True if writers are connected, false otherwise.
*/
bool hasWriters() const noexcept;
[[nodiscard]] bool hasWriters() const noexcept;

/**
* Wait for given number of writers to be online.
Expand All @@ -250,14 +250,14 @@ namespace DataStorm
*
* @return The names of the connected writers.
*/
std::vector<std::string> getConnectedWriters() const noexcept;
[[nodiscard]] std::vector<std::string> getConnectedWriters() const noexcept;

/**
* Get the keys for which writers are connected to this reader.
*
* @return The keys for which we have writers connected.
**/
std::vector<Key> getConnectedKeys() const noexcept;
[[nodiscard]] std::vector<Key> getConnectedKeys() const noexcept;

/**
* Returns all the unread samples.
Expand All @@ -278,7 +278,7 @@ namespace DataStorm
*
* @return True if there unread samples are queued, false otherwise.
*/
bool hasUnread() const noexcept;
[[nodiscard]] bool hasUnread() const noexcept;

/**
* Returns the next unread sample.
Expand Down Expand Up @@ -383,7 +383,7 @@ namespace DataStorm
*
* @return True if readers are connected, false otherwise.
*/
bool hasReaders() const noexcept;
[[nodiscard]] bool hasReaders() const noexcept;

/**
* Wait for given number of readers to be online.
Expand All @@ -405,14 +405,14 @@ namespace DataStorm
*
* @return The names of the connected readers.
*/
std::vector<std::string> getConnectedReaders() const noexcept;
[[nodiscard]] std::vector<std::string> getConnectedReaders() const noexcept;

/**
* Get the keys for which readers are connected to this writer.
*
* @return The keys for which we have writers connected.
**/
std::vector<Key> getConnectedKeys() const noexcept;
[[nodiscard]] std::vector<Key> getConnectedKeys() const noexcept;

/**
* Get the last written sample.
Expand Down
48 changes: 24 additions & 24 deletions cpp/include/DataStorm/InternalI.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ namespace DataStormI
{
public:
virtual ~Element() = default;
virtual std::string toString() const = 0;
virtual Ice::ByteSeq encode(const Ice::CommunicatorPtr&) const = 0;
virtual std::int64_t getId() const = 0;
[[nodiscard]] virtual std::string toString() const = 0;
[[nodiscard]] virtual Ice::ByteSeq encode(const Ice::CommunicatorPtr&) const = 0;
[[nodiscard]] virtual std::int64_t getId() const = 0;
};

class Key : public Filterable, public virtual Element
Expand All @@ -51,7 +51,7 @@ namespace DataStormI
{
public:
virtual ~KeyFactory() = default;
virtual std::shared_ptr<Key> get(std::int64_t) const = 0;
[[nodiscard]] virtual std::shared_ptr<Key> get(std::int64_t) const = 0;
virtual std::shared_ptr<Key> decode(const Ice::CommunicatorPtr&, const Ice::ByteSeq&) = 0;
bernardnormier marked this conversation as resolved.
Show resolved Hide resolved
};

Expand All @@ -63,7 +63,7 @@ namespace DataStormI
{
public:
virtual ~TagFactory() = default;
virtual std::shared_ptr<Tag> get(std::int64_t) const = 0;
[[nodiscard]] virtual std::shared_ptr<Tag> get(std::int64_t) const = 0;
virtual std::shared_ptr<Tag> decode(const Ice::CommunicatorPtr&, const Ice::ByteSeq&) = 0;
bernardnormier marked this conversation as resolved.
Show resolved Hide resolved
};

Expand Down Expand Up @@ -92,14 +92,14 @@ namespace DataStormI

Sample(DataStorm::SampleEvent event, const std::shared_ptr<Tag>& tag = nullptr) : event(event), tag(tag) {}

virtual bool hasValue() const = 0;
[[nodiscard]] virtual bool hasValue() const = 0;
virtual void setValue(const std::shared_ptr<Sample>&) = 0;

virtual void decode(const Ice::CommunicatorPtr&) = 0;
virtual const Ice::ByteSeq& encode(const Ice::CommunicatorPtr&) = 0;
virtual Ice::ByteSeq encodeValue(const Ice::CommunicatorPtr&) = 0;

const Ice::ByteSeq& getEncodedValue() const { return _encodedValue; }
[[nodiscard]] const Ice::ByteSeq& getEncodedValue() const { return _encodedValue; }

std::string session;
std::string origin;
Expand Down Expand Up @@ -132,24 +132,24 @@ namespace DataStormI
class Filter : public virtual Element
{
public:
virtual bool match(const std::shared_ptr<Filterable>&) const = 0;
virtual const std::string& getName() const = 0;
[[nodiscard]] virtual bool match(const std::shared_ptr<Filterable>&) const = 0;
[[nodiscard]] virtual const std::string& getName() const = 0;
};

class FilterFactory
{
public:
virtual ~FilterFactory() = default;

virtual std::shared_ptr<Filter> get(std::int64_t) const = 0;
[[nodiscard]] virtual std::shared_ptr<Filter> get(std::int64_t) const = 0;
};

class FilterManager
{
public:
virtual ~FilterManager() = default;

virtual std::shared_ptr<Filter> get(const std::string&, std::int64_t) const = 0;
[[nodiscard]] virtual std::shared_ptr<Filter> get(const std::string&, std::int64_t) const = 0;

virtual std::shared_ptr<Filter>
decode(const Ice::CommunicatorPtr&, const std::string&, const Ice::ByteSeq&) = 0;
Expand All @@ -162,8 +162,8 @@ namespace DataStormI

using Id = std::tuple<std::string, std::int64_t, std::int64_t>;

virtual std::vector<std::string> getConnectedElements() const = 0;
virtual std::vector<std::shared_ptr<Key>> getConnectedKeys() const = 0;
[[nodiscard]] virtual std::vector<std::string> getConnectedElements() const = 0;
[[nodiscard]] virtual std::vector<std::shared_ptr<Key>> getConnectedKeys() const = 0;
virtual void onConnectedKeys(
std::function<void(std::vector<std::shared_ptr<Key>>)>,
std::function<void(DataStorm::CallbackReason, std::shared_ptr<Key>)>) = 0;
Expand All @@ -172,19 +172,19 @@ namespace DataStormI
std::function<void(DataStorm::CallbackReason, std::string)>) = 0;

virtual void destroy() = 0;
virtual Ice::CommunicatorPtr getCommunicator() const = 0;
[[nodiscard]] virtual Ice::CommunicatorPtr getCommunicator() const = 0;
};

class DataReader : public virtual DataElement
{
public:
virtual bool hasWriters() = 0;
virtual void waitForWriters(int) = 0;
virtual int getInstanceCount() const = 0;
[[nodiscard]] virtual int getInstanceCount() const = 0;

virtual std::vector<std::shared_ptr<Sample>> getAllUnread() = 0;
virtual void waitForUnread(unsigned int) const = 0;
virtual bool hasUnread() const = 0;
[[nodiscard]] virtual bool hasUnread() const = 0;
virtual std::shared_ptr<Sample> getNextUnread() = 0;
bernardnormier marked this conversation as resolved.
Show resolved Hide resolved

virtual void onSamples(
Expand All @@ -195,11 +195,11 @@ namespace DataStormI
class DataWriter : public virtual DataElement
{
public:
virtual bool hasReaders() const = 0;
[[nodiscard]] virtual bool hasReaders() const = 0;
virtual void waitForReaders(int) const = 0;

virtual std::shared_ptr<Sample> getLast() const = 0;
virtual std::vector<std::shared_ptr<Sample>> getAll() const = 0;
[[nodiscard]] virtual std::shared_ptr<Sample> getLast() const = 0;
[[nodiscard]] virtual std::vector<std::shared_ptr<Sample>> getAll() const = 0;

virtual void publish(const std::shared_ptr<Key>&, const std::shared_ptr<Sample>&) = 0;
};
Expand All @@ -215,9 +215,9 @@ namespace DataStormI
virtual void setUpdater(const std::shared_ptr<Tag>&, Updater) = 0;

virtual void setUpdaters(std::map<std::shared_ptr<Tag>, Updater>) = 0;
virtual std::map<std::shared_ptr<Tag>, Updater> getUpdaters() const = 0;
[[nodiscard]] virtual std::map<std::shared_ptr<Tag>, Updater> getUpdaters() const = 0;

virtual std::string getName() const = 0;
[[nodiscard]] virtual std::string getName() const = 0;
virtual void destroy() = 0;
};

Expand All @@ -239,7 +239,7 @@ namespace DataStormI
Ice::ByteSeq = {}) = 0;

virtual void setDefaultConfig(DataStorm::ReaderConfig) = 0;
virtual bool hasWriters() const = 0;
[[nodiscard]] virtual bool hasWriters() const = 0;
virtual void waitForWriters(int) const = 0;
};

Expand All @@ -250,7 +250,7 @@ namespace DataStormI
create(const std::vector<std::shared_ptr<Key>>&, std::string, DataStorm::WriterConfig) = 0;
bernardnormier marked this conversation as resolved.
Show resolved Hide resolved

virtual void setDefaultConfig(DataStorm::WriterConfig) = 0;
virtual bool hasReaders() const = 0;
[[nodiscard]] virtual bool hasReaders() const = 0;
virtual void waitForReaders(int) const = 0;
};

Expand All @@ -275,7 +275,7 @@ namespace DataStormI
std::shared_ptr<FilterManager>,
std::shared_ptr<FilterManager>) = 0;

virtual Ice::CommunicatorPtr getCommunicator() const = 0;
[[nodiscard]] virtual Ice::CommunicatorPtr getCommunicator() const = 0;
};
}

Expand Down
Loading
Loading