diff --git a/cpp/include/DataStorm/DataStorm.h b/cpp/include/DataStorm/DataStorm.h index af9605cbca4..640f68493c5 100644 --- a/cpp/include/DataStorm/DataStorm.h +++ b/cpp/include/DataStorm/DataStorm.h @@ -24,7 +24,6 @@ namespace DataStorm { - /** * A sample provides information about a data element update. * @@ -2083,7 +2082,6 @@ namespace DataStorm { return _topicFactory->getCommunicator(); } - } #if defined(__clang__) diff --git a/cpp/include/DataStorm/InternalI.h b/cpp/include/DataStorm/InternalI.h index 81d8b275edd..f67cf339bad 100644 --- a/cpp/include/DataStorm/InternalI.h +++ b/cpp/include/DataStorm/InternalI.h @@ -43,7 +43,7 @@ namespace DataStormI virtual std::int64_t getId() const = 0; }; - class Key : public Filterable, virtual public Element + class Key : public Filterable, public virtual Element { }; @@ -55,7 +55,7 @@ namespace DataStormI virtual std::shared_ptr decode(const Ice::CommunicatorPtr&, const Ice::ByteSeq&) = 0; }; - class Tag : virtual public Element + class Tag : public virtual Element { }; @@ -129,7 +129,7 @@ namespace DataStormI std::int64_t) = 0; }; - class Filter : virtual public Element + class Filter : public virtual Element { public: virtual bool match(const std::shared_ptr&) const = 0; @@ -176,7 +176,7 @@ namespace DataStormI virtual Ice::CommunicatorPtr getCommunicator() const = 0; }; - class DataReader : virtual public DataElement + class DataReader : public virtual DataElement { public: virtual bool hasWriters() = 0; @@ -193,7 +193,7 @@ namespace DataStormI std::function&)>) = 0; }; - class DataWriter : virtual public DataElement + class DataWriter : public virtual DataElement { public: virtual bool hasReaders() const = 0; @@ -222,7 +222,7 @@ namespace DataStormI virtual void destroy() = 0; }; - class TopicReader : virtual public Topic + class TopicReader : public virtual Topic { public: virtual std::shared_ptr createFiltered( @@ -244,7 +244,7 @@ namespace DataStormI virtual void waitForWriters(int) const = 0; }; - class TopicWriter : virtual public Topic + class TopicWriter : public virtual Topic { public: virtual std::shared_ptr diff --git a/cpp/include/DataStorm/InternalT.h b/cpp/include/DataStorm/InternalT.h index 04a4cceef91..aefc4088b1f 100644 --- a/cpp/include/DataStorm/InternalT.h +++ b/cpp/include/DataStorm/InternalT.h @@ -106,24 +106,24 @@ namespace DataStormI } }; - template class AbstractElementT : virtual public Element + template class AbstractElementT : public virtual Element { public: template AbstractElementT(TT&& v, std::int64_t id) : _value(std::forward(v)), _id(id) {} - virtual std::string toString() const override + std::string toString() const override { std::ostringstream os; os << _id << ':' << Stringifier::toString(_value); return os.str(); } - virtual Ice::ByteSeq encode(const Ice::CommunicatorPtr& communicator) const override + Ice::ByteSeq encode(const Ice::CommunicatorPtr& communicator) const override { return EncoderT::encode(communicator, _value); } - virtual std::int64_t getId() const override { return _id; } + std::int64_t getId() const override { return _id; } const T& get() const { return _value; } @@ -242,26 +242,23 @@ namespace DataStormI std::int64_t _nextId; }; - template class KeyT : public Key, public AbstractElementT + template class KeyT final : public Key, public AbstractElementT { public: - virtual std::string toString() const override { return "k" + AbstractElementT::toString(); } + std::string toString() const final { return "k" + AbstractElementT::toString(); } using AbstractElementT::AbstractElementT; using BaseClassType = Key; }; - template class KeyFactoryT : public KeyFactory, public AbstractFactoryT> + template class KeyFactoryT final : public KeyFactory, public AbstractFactoryT> { public: using AbstractFactoryT>::AbstractFactoryT; - virtual std::shared_ptr get(std::int64_t id) const override - { - return AbstractFactoryT>::getImpl(id); - } + std::shared_ptr get(std::int64_t id) const final { return AbstractFactoryT>::getImpl(id); } - virtual std::shared_ptr decode(const Ice::CommunicatorPtr& communicator, const Ice::ByteSeq& data) override + std::shared_ptr decode(const Ice::CommunicatorPtr& communicator, const Ice::ByteSeq& data) final { return AbstractFactoryT>::create(DecoderT::decode(communicator, data)); } @@ -274,26 +271,23 @@ namespace DataStormI } }; - template class TagT : public Tag, public AbstractElementT + template class TagT final : public Tag, public AbstractElementT { public: - virtual std::string toString() const override { return "t" + AbstractElementT::toString(); } + std::string toString() const final { return "t" + AbstractElementT::toString(); } using AbstractElementT::AbstractElementT; using BaseClassType = Tag; }; - template class TagFactoryT : public TagFactory, public AbstractFactoryT> + template class TagFactoryT final : public TagFactory, public AbstractFactoryT> { public: using AbstractFactoryT>::AbstractFactoryT; - virtual std::shared_ptr get(std::int64_t id) const override - { - return AbstractFactoryT>::getImpl(id); - } + std::shared_ptr get(std::int64_t id) const final { return AbstractFactoryT>::getImpl(id); } - virtual std::shared_ptr decode(const Ice::CommunicatorPtr& communicator, const Ice::ByteSeq& data) override + std::shared_ptr decode(const Ice::CommunicatorPtr& communicator, const Ice::ByteSeq& data) final { return AbstractFactoryT>::create(DecoderT::decode(communicator, data)); } @@ -307,7 +301,7 @@ namespace DataStormI }; template - class SampleT : public Sample, public std::enable_shared_from_this> + class SampleT final : public Sample, public std::enable_shared_from_this> { public: SampleT( @@ -357,9 +351,9 @@ namespace DataStormI _hasValue = true; } - virtual bool hasValue() const override { return _hasValue; } + bool hasValue() const final { return _hasValue; } - virtual void setValue(const std::shared_ptr& sample) override + void setValue(const std::shared_ptr& sample) final { if (sample) { @@ -373,7 +367,7 @@ namespace DataStormI _hasValue = true; } - virtual const Ice::ByteSeq& encode(const Ice::CommunicatorPtr& communicator) override + const Ice::ByteSeq& encode(const Ice::CommunicatorPtr& communicator) final { if (_encodedValue.empty()) { @@ -382,13 +376,13 @@ namespace DataStormI return _encodedValue; } - virtual Ice::ByteSeq encodeValue(const Ice::CommunicatorPtr& communicator) override + Ice::ByteSeq encodeValue(const Ice::CommunicatorPtr& communicator) final { assert(_hasValue || event == DataStorm::SampleEvent::Remove); return EncoderT::encode(communicator, _value); } - virtual void decode(const Ice::CommunicatorPtr& communicator) override + void decode(const Ice::CommunicatorPtr& communicator) final { if (!_encodedValue.empty()) { @@ -403,10 +397,10 @@ namespace DataStormI Value _value; }; - template class SampleFactoryT : public SampleFactory + template class SampleFactoryT final : public SampleFactory { public: - virtual std::shared_ptr create( + std::shared_ptr create( std::string session, std::string origin, std::int64_t id, @@ -414,7 +408,7 @@ namespace DataStormI const std::shared_ptr& key, const std::shared_ptr& tag, Ice::ByteSeq value, - std::int64_t timestamp) + std::int64_t timestamp) final { return std::make_shared>( std::move(session), @@ -428,7 +422,7 @@ namespace DataStormI } }; - template class FilterT : public Filter, public AbstractElementT + template class FilterT final : public Filter, public AbstractElementT { public: template @@ -436,14 +430,14 @@ namespace DataStormI { } - virtual std::string toString() const override { return "f" + AbstractElementT::toString(); } + std::string toString() const final { return "f" + AbstractElementT::toString(); } - virtual bool match(const std::shared_ptr& value) const override + bool match(const std::shared_ptr& value) const final { return _lambda(std::static_pointer_cast(value)->get()); } - virtual const std::string& getName() const override { return _name; } + const std::string& getName() const final { return _name; } template void init(const std::string& name, FF&& lambda) { @@ -459,18 +453,17 @@ namespace DataStormI }; template - class FilterFactoryT : public FilterFactory, public AbstractFactoryT> + class FilterFactoryT final : public FilterFactory, public AbstractFactoryT> { public: FilterFactoryT() {} - virtual std::shared_ptr get(std::int64_t id) const override + std::shared_ptr get(std::int64_t id) const final { return AbstractFactoryT>::getImpl(id); } - virtual std::shared_ptr - decode(const Ice::CommunicatorPtr& communicator, const Ice::ByteSeq& data) override + std::shared_ptr decode(const Ice::CommunicatorPtr& communicator, const Ice::ByteSeq& data) final { return AbstractFactoryT>::create(DecoderT::decode(communicator, data)); } @@ -483,7 +476,7 @@ namespace DataStormI } }; - template class FilterManagerT : public FilterManager + template class FilterManagerT final : public FilterManager { using Value = typename std::remove_reference().get())>::type; @@ -496,7 +489,7 @@ namespace DataStormI virtual std::shared_ptr decode(const Ice::CommunicatorPtr&, const Ice::ByteSeq&) = 0; }; - template struct FactoryT : Factory + template struct FactoryT final : Factory { FactoryT(std::string name, std::function(const Criteria&)> lambda) : name(std::move(name)), @@ -511,9 +504,9 @@ namespace DataStormI return filter; } - virtual std::shared_ptr get(std::int64_t id) const { return filterFactory.get(id); } + std::shared_ptr get(std::int64_t id) const final { return filterFactory.get(id); } - virtual std::shared_ptr decode(const Ice::CommunicatorPtr& communicator, const Ice::ByteSeq& data) + std::shared_ptr decode(const Ice::CommunicatorPtr& communicator, const Ice::ByteSeq& data) final { return create(DecoderT::decode(communicator, data)); } @@ -543,8 +536,8 @@ namespace DataStormI return factory->create(criteria); } - virtual std::shared_ptr - decode(const Ice::CommunicatorPtr& communicator, const std::string& name, const Ice::ByteSeq& data) override + std::shared_ptr + decode(const Ice::CommunicatorPtr& communicator, const std::string& name, const Ice::ByteSeq& data) final { auto p = _factories.find(name); if (p == _factories.end()) @@ -555,7 +548,7 @@ namespace DataStormI return p->second->decode(communicator, data); } - virtual std::shared_ptr get(const std::string& name, std::int64_t id) const override + std::shared_ptr get(const std::string& name, std::int64_t id) const final { auto p = _factories.find(name); if (p == _factories.end()) diff --git a/cpp/include/DataStorm/Node.h b/cpp/include/DataStorm/Node.h index c505a75f02e..bdb7cfe5f40 100644 --- a/cpp/include/DataStorm/Node.h +++ b/cpp/include/DataStorm/Node.h @@ -19,10 +19,10 @@ namespace DataStorm * * @headerfile DataStorm/DataStorm.h */ - class DATASTORM_API NodeShutdownException : public std::exception + class DATASTORM_API NodeShutdownException final : public std::exception { public: - virtual const char* what() const noexcept; + const char* what() const noexcept final; }; /** diff --git a/cpp/src/DataStorm/CallbackExecutor.h b/cpp/src/DataStorm/CallbackExecutor.h index 99429e48312..ec166185cc1 100644 --- a/cpp/src/DataStorm/CallbackExecutor.h +++ b/cpp/src/DataStorm/CallbackExecutor.h @@ -16,7 +16,7 @@ namespace DataStormI { class DataElementI; - class CallbackExecutor + class CallbackExecutor final { public: CallbackExecutor(std::function call)> customExecutor); diff --git a/cpp/src/DataStorm/ConnectionManager.h b/cpp/src/DataStorm/ConnectionManager.h index 35a9fac0ee9..d4ddc6611f7 100644 --- a/cpp/src/DataStorm/ConnectionManager.h +++ b/cpp/src/DataStorm/ConnectionManager.h @@ -12,7 +12,7 @@ namespace DataStormI { class CallbackExecutor; - class ConnectionManager : public std::enable_shared_from_this + class ConnectionManager final : public std::enable_shared_from_this { public: ConnectionManager(const std::shared_ptr&); diff --git a/cpp/src/DataStorm/DataElementI.h b/cpp/src/DataStorm/DataElementI.h index 11381e4c0ba..bd55f90baf6 100644 --- a/cpp/src/DataStorm/DataElementI.h +++ b/cpp/src/DataStorm/DataElementI.h @@ -25,7 +25,8 @@ namespace DataStormI class CallbackExecutor; class TraceLevels; - class DataElementI : virtual public DataElement, public std::enable_shared_from_this + // Base class for DataReaderI and DataWriterI. + class DataElementI : public virtual DataElement, public std::enable_shared_from_this { protected: struct Subscriber @@ -134,9 +135,9 @@ namespace DataStormI public: DataElementI(TopicI*, std::string, std::int64_t, const DataStorm::Config&); - virtual ~DataElementI(); + ~DataElementI() override; - virtual void destroy() override; + void destroy() override; void attach( std::int64_t, @@ -201,12 +202,14 @@ namespace DataStormI const std::string&, bool); - virtual std::vector> getConnectedKeys() const override; - virtual std::vector getConnectedElements() const override; - virtual void onConnectedKeys( + std::vector> getConnectedKeys() const override; + std::vector getConnectedElements() const override; + + void onConnectedKeys( std::function>)>, std::function)>) override; - virtual void onConnectedElements( + + void onConnectedElements( std::function)>, std::function) override; @@ -217,6 +220,7 @@ namespace DataStormI int, const std::chrono::time_point&, bool); + virtual DataStormContract::DataSamples getSamples( const std::shared_ptr&, const std::shared_ptr&, @@ -233,7 +237,8 @@ namespace DataStormI bool); virtual std::string toString() const = 0; - virtual Ice::CommunicatorPtr getCommunicator() const override; + + Ice::CommunicatorPtr getCommunicator() const override; std::int64_t getId() const { return _id; } @@ -287,21 +292,22 @@ namespace DataStormI Ice::ByteSeq, const DataStorm::ReaderConfig&); - virtual int getInstanceCount() const override; + int getInstanceCount() const override; - virtual std::vector> getAllUnread() override; - virtual void waitForUnread(unsigned int) const override; - virtual bool hasUnread() const override; - virtual std::shared_ptr getNextUnread() override; + std::vector> getAllUnread() override; + void waitForUnread(unsigned int) const override; + bool hasUnread() const override; + std::shared_ptr getNextUnread() override; - virtual void initSamples( + void initSamples( const std::vector>&, std::int64_t, std::int64_t, int, const std::chrono::time_point&, bool) override; - virtual void queue( + + void queue( const std::shared_ptr&, int, const std::shared_ptr&, @@ -309,13 +315,13 @@ namespace DataStormI const std::chrono::time_point&, bool) override; - virtual void onSamples( + void onSamples( std::function>&)>, std::function&)>) override; protected: virtual bool matchKey(const std::shared_ptr&) const = 0; - virtual bool addConnectedKey(const std::shared_ptr&, const std::shared_ptr&) override; + bool addConnectedKey(const std::shared_ptr&, const std::shared_ptr&) override; TopicReaderI* _parent; @@ -332,7 +338,7 @@ namespace DataStormI public: DataWriterI(TopicWriterI*, std::string, std::int64_t, const DataStorm::WriterConfig&); - virtual void publish(const std::shared_ptr&, const std::shared_ptr&) override; + void publish(const std::shared_ptr&, const std::shared_ptr&) override; protected: virtual void send(const std::shared_ptr&, const std::shared_ptr&) const = 0; @@ -343,7 +349,7 @@ namespace DataStormI std::shared_ptr _last; }; - class KeyDataReaderI : public DataReaderI + class KeyDataReaderI final : public DataReaderI { public: KeyDataReaderI( @@ -355,20 +361,20 @@ namespace DataStormI Ice::ByteSeq, const DataStorm::ReaderConfig&); - virtual void destroyImpl() override; + void destroyImpl() final; - virtual void waitForWriters(int) override; - virtual bool hasWriters() override; + void waitForWriters(int) final; + bool hasWriters() final; - virtual std::string toString() const override; + std::string toString() const final; private: - virtual bool matchKey(const std::shared_ptr&) const override; + bool matchKey(const std::shared_ptr&) const final; const std::vector> _keys; }; - class KeyDataWriterI : public DataWriterI + class KeyDataWriterI final : public DataWriterI { public: KeyDataWriterI( @@ -378,30 +384,31 @@ namespace DataStormI const std::vector>&, const DataStorm::WriterConfig&); - virtual void destroyImpl() override; + void destroyImpl() final; - virtual void waitForReaders(int) const override; - virtual bool hasReaders() const override; + void waitForReaders(int) const final; + bool hasReaders() const final; - virtual std::shared_ptr getLast() const override; - virtual std::vector> getAll() const override; + std::shared_ptr getLast() const final; + std::vector> getAll() const final; - virtual std::string toString() const override; - virtual DataStormContract::DataSamples getSamples( + std::string toString() const final; + + DataStormContract::DataSamples getSamples( const std::shared_ptr&, const std::shared_ptr&, const std::shared_ptr&, std::int64_t, - const std::chrono::time_point&) override; + const std::chrono::time_point&) final; private: - virtual void send(const std::shared_ptr&, const std::shared_ptr&) const override; - virtual void forward(const Ice::ByteSeq&, const Ice::Current&) const override; + void send(const std::shared_ptr&, const std::shared_ptr&) const final; + void forward(const Ice::ByteSeq&, const Ice::Current&) const final; const std::vector> _keys; }; - class FilteredDataReaderI : public DataReaderI + class FilteredDataReaderI final : public DataReaderI { public: FilteredDataReaderI( @@ -413,15 +420,15 @@ namespace DataStormI Ice::ByteSeq, const DataStorm::ReaderConfig&); - virtual void destroyImpl() override; + void destroyImpl() final; - virtual void waitForWriters(int) override; - virtual bool hasWriters() override; + void waitForWriters(int) final; + bool hasWriters() final; - virtual std::string toString() const override; + std::string toString() const final; private: - virtual bool matchKey(const std::shared_ptr&) const override; + bool matchKey(const std::shared_ptr&) const final; const std::shared_ptr _filter; }; diff --git a/cpp/src/DataStorm/ForwarderManager.h b/cpp/src/DataStorm/ForwarderManager.h index fe4a6505869..455b1972baa 100644 --- a/cpp/src/DataStorm/ForwarderManager.h +++ b/cpp/src/DataStorm/ForwarderManager.h @@ -13,7 +13,7 @@ namespace DataStormI { - class ForwarderManager : public Ice::BlobjectAsync + class ForwarderManager final : public Ice::BlobjectAsync { public: using Response = std::function; @@ -57,11 +57,11 @@ namespace DataStormI void destroy(); private: - virtual void ice_invokeAsync( + void ice_invokeAsync( Ice::ByteSeq, std::function, std::function, - const Ice::Current&); + const Ice::Current&) final; const Ice::ObjectAdapterPtr _adapter; const std::string _category; diff --git a/cpp/src/DataStorm/Instance.h b/cpp/src/DataStorm/Instance.h index a44a2a22e8b..05e6fc17e62 100644 --- a/cpp/src/DataStorm/Instance.h +++ b/cpp/src/DataStorm/Instance.h @@ -22,7 +22,7 @@ namespace DataStormI class NodeI; class CallbackExecutor; - class Instance : public std::enable_shared_from_this + class Instance final : public std::enable_shared_from_this { public: Instance( diff --git a/cpp/src/DataStorm/NodeI.h b/cpp/src/DataStorm/NodeI.h index e199dcea8ea..394a37e4e65 100644 --- a/cpp/src/DataStorm/NodeI.h +++ b/cpp/src/DataStorm/NodeI.h @@ -20,11 +20,11 @@ namespace DataStormI class PublisherSessionI; class SubscriberSessionI; - class NodeI final : virtual public DataStormContract::Node, public std::enable_shared_from_this + class NodeI final : public virtual DataStormContract::Node, public std::enable_shared_from_this { public: NodeI(const std::shared_ptr&); - virtual ~NodeI(); + ~NodeI() final; void init(); void destroy(bool); diff --git a/cpp/src/DataStorm/NodeSessionI.h b/cpp/src/DataStorm/NodeSessionI.h index 3fce2ad98cd..f2a09e2df79 100644 --- a/cpp/src/DataStorm/NodeSessionI.h +++ b/cpp/src/DataStorm/NodeSessionI.h @@ -13,7 +13,7 @@ namespace DataStormI { class TraceLevels; - class NodeSessionI : public std::enable_shared_from_this + class NodeSessionI final : public std::enable_shared_from_this { public: NodeSessionI(std::shared_ptr, std::optional, Ice::ConnectionPtr, bool); diff --git a/cpp/src/DataStorm/NodeSessionManager.h b/cpp/src/DataStorm/NodeSessionManager.h index 1ff9cf0e216..9363138b49b 100644 --- a/cpp/src/DataStorm/NodeSessionManager.h +++ b/cpp/src/DataStorm/NodeSessionManager.h @@ -17,7 +17,7 @@ namespace DataStormI class TraceLevels; class NodeI; - class NodeSessionManager : public std::enable_shared_from_this + class NodeSessionManager final : public std::enable_shared_from_this { public: NodeSessionManager(const std::shared_ptr&, const std::shared_ptr&); diff --git a/cpp/src/DataStorm/SessionI.h b/cpp/src/DataStorm/SessionI.h index a31a3dd8d31..e797ef51a11 100644 --- a/cpp/src/DataStorm/SessionI.h +++ b/cpp/src/DataStorm/SessionI.h @@ -24,7 +24,7 @@ namespace DataStormI class Instance; class TraceLevels; - class SessionI : virtual public DataStormContract::Session, public std::enable_shared_from_this + class SessionI : public virtual DataStormContract::Session, public std::enable_shared_from_this { protected: struct ElementSubscriber @@ -353,12 +353,12 @@ namespace DataStormI public: SubscriberSessionI(const std::shared_ptr&, DataStormContract::NodePrx, DataStormContract::SessionPrx); - virtual void s(std::int64_t, std::int64_t, DataStormContract::DataSample, const Ice::Current&) final; + void s(std::int64_t, std::int64_t, DataStormContract::DataSample, const Ice::Current&) final; private: - virtual std::vector> getTopics(const std::string&) const final; - virtual void reconnect(DataStormContract::NodePrx) final; - virtual void remove() final; + std::vector> getTopics(const std::string&) const final; + void reconnect(DataStormContract::NodePrx) final; + void remove() final; }; class PublisherSessionI : public SessionI, public DataStormContract::PublisherSession diff --git a/cpp/src/DataStorm/TopicI.cpp b/cpp/src/DataStorm/TopicI.cpp index b0da671e1db..33dbb82e862 100644 --- a/cpp/src/DataStorm/TopicI.cpp +++ b/cpp/src/DataStorm/TopicI.cpp @@ -36,25 +36,25 @@ namespace { next->setValue(previous); }; // The always match filter always matches the value, it's used by the any key reader/writer. - class AlwaysMatchFilter : public Filter + class AlwaysMatchFilter final : public Filter { public: - virtual string toString() const { return "f1:alwaysmatch"; } + string toString() const final { return "f1:alwaysmatch"; } - virtual const string& getName() const + const string& getName() const final { static string alwaysmatch("alwaysmatch"); return alwaysmatch; } - virtual Ice::ByteSeq encode(const Ice::CommunicatorPtr&) const { return {}; } + Ice::ByteSeq encode(const Ice::CommunicatorPtr&) const final { return {}; } - virtual int64_t getId() const + int64_t getId() const final { return 1; // 1 is reserved for the match all filter. } - virtual bool match(const shared_ptr&) const { return true; } + bool match(const shared_ptr&) const final { return true; } }; const auto alwaysMatchFilter = make_shared(); }