ContentFilteredTopicImpl.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_CONTENTFILTEREDTOPICIMPL_H
00009 #define OPENDDS_DCPS_CONTENTFILTEREDTOPICIMPL_H
00010 
00011 #ifndef OPENDDS_NO_CONTENT_FILTERED_TOPIC
00012 
00013 #include "dds/DCPS/TopicDescriptionImpl.h"
00014 #include "dds/DCPS/FilterEvaluator.h"
00015 #include "dds/DCPS/PoolAllocator.h"
00016 
00017 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00018 #pragma once
00019 #endif /* ACE_LACKS_PRAGMA_ONCE */
00020 
00021 namespace OpenDDS {
00022 namespace DCPS {
00023 
00024 class DataReaderImpl;
00025 
00026 class OpenDDS_Dcps_Export ContentFilteredTopicImpl
00027   : public virtual OpenDDS::DCPS::LocalObject<DDS::ContentFilteredTopic>
00028   , public virtual TopicDescriptionImpl {
00029 public:
00030   ContentFilteredTopicImpl(const char* name, DDS::Topic_ptr related_topic,
00031     const char* filter_expression, const DDS::StringSeq& expression_parameters,
00032     DomainParticipantImpl* participant);
00033 
00034   virtual ~ContentFilteredTopicImpl() {}
00035 
00036   char* get_filter_expression();
00037 
00038   DDS::ReturnCode_t get_expression_parameters(DDS::StringSeq& parameters);
00039 
00040   DDS::ReturnCode_t set_expression_parameters(const DDS::StringSeq& parameters);
00041 
00042   DDS::Topic_ptr get_related_topic();
00043 
00044   template<typename Sample>
00045   bool filter(const Sample& s) const
00046   {
00047     ACE_GUARD_RETURN(ACE_Recursive_Thread_Mutex, guard, lock_, false);
00048     return filter_eval_.eval(s, expression_parameters_);
00049   }
00050 
00051   void add_reader(DataReaderImpl& reader);
00052   void remove_reader(DataReaderImpl& reader);
00053 
00054   const char* get_filter_class_name () const
00055   {
00056     return filter_eval_.usesExtendedGrammar () ? "OPENDDSSQL" : "DDSSQL";
00057   }
00058 
00059 private:
00060   OPENDDS_STRING filter_expression_;
00061   FilterEvaluator filter_eval_;
00062   DDS::StringSeq expression_parameters_;
00063   DDS::Topic_var related_topic_;
00064   OPENDDS_VECTOR(DataReaderImpl*) readers_;
00065 
00066   /// Concurrent access to expression_parameters_ and readers_
00067   mutable ACE_Recursive_Thread_Mutex lock_;
00068 };
00069 
00070 } // namespace DCPS
00071 } // namespace OpenDDS
00072 
00073 #endif // OPENDDS_NO_CONTENT_FILTERED_TOPIC
00074 
00075 #endif

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