Line data Source code
1 : /* 2 : * 3 : * 4 : * Distributed under the OpenDDS License. 5 : * See: http://www.opendds.org/license.html 6 : */ 7 : 8 : #ifndef OPENDDS_DCPS_MULTITOPICIMPL_H 9 : #define OPENDDS_DCPS_MULTITOPICIMPL_H 10 : 11 : #ifndef OPENDDS_NO_MULTI_TOPIC 12 : 13 : #include "TopicDescriptionImpl.h" 14 : #include "FilterEvaluator.h" 15 : 16 : #include "PoolAllocator.h" 17 : #include <utility> 18 : 19 : #if !defined (ACE_LACKS_PRAGMA_ONCE) 20 : #pragma once 21 : #endif /* ACE_LACKS_PRAGMA_ONCE */ 22 : 23 : OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL 24 : 25 : namespace OpenDDS { 26 : namespace DCPS { 27 : 28 : class OpenDDS_Dcps_Export MultiTopicImpl 29 : : public virtual OpenDDS::DCPS::LocalObject<DDS::MultiTopic> 30 : , public virtual TopicDescriptionImpl { 31 : public: 32 : MultiTopicImpl(const char* name, const char* type_name, 33 : const char* subscription_expression, 34 : const DDS::StringSeq& expression_parameters, 35 : DomainParticipantImpl* participant); 36 : 37 : virtual ~MultiTopicImpl(); 38 : 39 : char* get_subscription_expression(); 40 : 41 : DDS::ReturnCode_t get_expression_parameters(DDS::StringSeq& parameters); 42 : 43 : DDS::ReturnCode_t set_expression_parameters(const DDS::StringSeq& parameters); 44 : 45 : struct SubjectFieldSpec { 46 : OPENDDS_STRING incoming_name_; 47 : OPENDDS_STRING resulting_name_; 48 : 49 0 : explicit SubjectFieldSpec(const OPENDDS_STRING& inc, 50 : const OPENDDS_STRING& res = "") 51 0 : : incoming_name_(inc) 52 0 : , resulting_name_(res == "" ? inc : res) 53 0 : {} 54 : }; 55 : 56 0 : const std::vector<SubjectFieldSpec>& get_aggregation() const 57 : { 58 0 : return aggregation_; 59 : } 60 : 61 0 : const std::vector<OPENDDS_STRING>& get_selection() const 62 : { 63 0 : return selection_; 64 : } 65 : 66 : template<typename Sample> 67 0 : bool filter(const Sample& s) const 68 : { 69 0 : if (!filter_eval_) return true; 70 0 : ACE_GUARD_RETURN(ACE_Recursive_Thread_Mutex, guard, lock_, false); 71 0 : return filter_eval_->eval(s, expression_parameters_); 72 0 : } 73 : 74 : private: 75 : OPENDDS_STRING subscription_expression_; 76 : DDS::StringSeq expression_parameters_; 77 : unique_ptr<FilterEvaluator> filter_eval_; 78 : 79 : std::vector<SubjectFieldSpec> aggregation_; 80 : std::vector<OPENDDS_STRING> selection_; 81 : 82 : /// Concurrent access to expression_parameters_ 83 : mutable ACE_Recursive_Thread_Mutex lock_; 84 : }; 85 : 86 : } // namespace DCPS 87 : } // namespace OpenDDS 88 : 89 : OPENDDS_END_VERSIONED_NAMESPACE_DECL 90 : 91 : #endif // OPENDDS_NO_MULTI_TOPIC 92 : 93 : #endif