MultiTopicImpl.h

Go to the documentation of this file.
00001 /*
00002  *
00003  *
00004  * Distributed under the OpenDDS License.
00005  * See: http://www.opendds.org/license.html
00006  */
00007 
00008 #ifndef OPENDDS_DCPS_MULTITOPICIMPL_H
00009 #define OPENDDS_DCPS_MULTITOPICIMPL_H
00010 
00011 #ifndef OPENDDS_NO_MULTI_TOPIC
00012 
00013 #include "dds/DCPS/TopicDescriptionImpl.h"
00014 #include "dds/DCPS/FilterEvaluator.h"
00015 
00016 #include "PoolAllocator.h"
00017 #include <utility>
00018 
00019 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00020 #pragma once
00021 #endif /* ACE_LACKS_PRAGMA_ONCE */
00022 
00023 namespace OpenDDS {
00024 namespace DCPS {
00025 
00026 class OpenDDS_Dcps_Export MultiTopicImpl
00027   : public virtual OpenDDS::DCPS::LocalObject<DDS::MultiTopic>
00028   , public virtual TopicDescriptionImpl {
00029 public:
00030   MultiTopicImpl(const char* name, const char* type_name,
00031     const char* subscription_expression,
00032     const DDS::StringSeq& expression_parameters,
00033     DomainParticipantImpl* participant);
00034 
00035   virtual ~MultiTopicImpl();
00036 
00037   char* get_subscription_expression();
00038 
00039   DDS::ReturnCode_t get_expression_parameters(DDS::StringSeq& parameters);
00040 
00041   DDS::ReturnCode_t set_expression_parameters(const DDS::StringSeq& parameters);
00042 
00043   struct SubjectFieldSpec {
00044     OPENDDS_STRING incoming_name_;
00045     OPENDDS_STRING resulting_name_;
00046 
00047     explicit SubjectFieldSpec(const OPENDDS_STRING& inc,
00048                               const OPENDDS_STRING& res = "")
00049       : incoming_name_(inc)
00050       , resulting_name_(res == "" ? inc : res)
00051     {}
00052   };
00053 
00054   const std::vector<SubjectFieldSpec>& get_aggregation() const
00055   {
00056     return aggregation_;
00057   }
00058 
00059   const std::vector<OPENDDS_STRING>& get_selection() const
00060   {
00061     return selection_;
00062   }
00063 
00064   template<typename Sample>
00065   bool filter(const Sample& s) const
00066   {
00067     if (!filter_eval_) return true;
00068     ACE_GUARD_RETURN(ACE_Recursive_Thread_Mutex, guard, lock_, false);
00069     return filter_eval_->eval(s, expression_parameters_);
00070   }
00071 
00072 private:
00073   OPENDDS_STRING subscription_expression_;
00074   DDS::StringSeq expression_parameters_;
00075   FilterEvaluator* filter_eval_;
00076 
00077   std::vector<SubjectFieldSpec> aggregation_;
00078   std::vector<OPENDDS_STRING> selection_;
00079 
00080   ///concurrent access to expression_parameters_
00081   mutable ACE_Recursive_Thread_Mutex lock_;
00082 };
00083 
00084 } // namespace DCPS
00085 } // namespace OpenDDS
00086 
00087 #endif // OPENDDS_NO_MULTI_TOPIC
00088 
00089 #endif

Generated on Fri Feb 12 20:05:24 2016 for OpenDDS by  doxygen 1.4.7