Skip to content

Commit

Permalink
Fix DataStorm filter initialization (#3278)
Browse files Browse the repository at this point in the history
  • Loading branch information
pepone authored Dec 17, 2024
1 parent 47d5c39 commit 684221b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 17 deletions.
1 change: 0 additions & 1 deletion cpp/include/DataStorm/InternalI.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ namespace DataStormI
virtual ~FilterFactory() = default;

virtual std::shared_ptr<Filter> get(std::int64_t) const = 0;
virtual std::shared_ptr<Filter> decode(const Ice::CommunicatorPtr&, const Ice::ByteSeq&) = 0;
};

class FilterManager
Expand Down
23 changes: 7 additions & 16 deletions cpp/include/DataStorm/InternalT.h
Original file line number Diff line number Diff line change
Expand Up @@ -425,8 +425,11 @@ namespace DataStormI
template<typename C, typename V> class FilterT final : public Filter, public AbstractElementT<C>
{
public:
template<typename CC>
FilterT(CC&& criteria, std::int64_t id) : AbstractElementT<C>::AbstractElementT(std::forward<CC>(criteria), id)
template<typename CC, typename FF>
FilterT(CC&& criteria, std::string name, FF lambda, std::int64_t id)
: AbstractElementT<C>::AbstractElementT(std::forward<CC>(criteria), id),
_name(std::move(name)),
_lambda(std::move(lambda))
{
}

Expand All @@ -439,12 +442,6 @@ namespace DataStormI

const std::string& getName() const final { return _name; }

template<typename FF> void init(const std::string& name, FF&& lambda)
{
_name = name;
_lambda = std::forward<FF>(lambda);
}

using BaseClassType = Filter;

private:
Expand All @@ -463,11 +460,6 @@ namespace DataStormI
return AbstractFactoryT<C, FilterT<C, V>>::getImpl(id);
}

std::shared_ptr<Filter> decode(const Ice::CommunicatorPtr& communicator, const Ice::ByteSeq& data) final
{
return AbstractFactoryT<C, FilterT<C, V>>::create(DecoderT<C>::decode(communicator, data));
}

static std::shared_ptr<FilterFactoryT<C, V>> createFactory()
{
auto f = std::make_shared<FilterFactoryT<C, V>>();
Expand Down Expand Up @@ -499,9 +491,8 @@ namespace DataStormI

std::shared_ptr<Filter> create(Criteria criteria)
{
auto filter = std::static_pointer_cast<FilterT<Criteria, ValueT>>(filterFactory.create(criteria));
filter->init(name, lambda(filter->get()));
return filter;
return std::static_pointer_cast<FilterT<Criteria, ValueT>>(
filterFactory.create(criteria, name, lambda(criteria)));
}

std::shared_ptr<Filter> get(std::int64_t id) const final { return filterFactory.get(id); }
Expand Down

0 comments on commit 684221b

Please sign in to comment.