OpenDDS::DCPS::ContentFilteredTopicImpl Class Reference

#include <ContentFilteredTopicImpl.h>

Inheritance diagram for OpenDDS::DCPS::ContentFilteredTopicImpl:

Inheritance graph
[legend]
Collaboration diagram for OpenDDS::DCPS::ContentFilteredTopicImpl:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 ContentFilteredTopicImpl (const char *name, DDS::Topic_ptr related_topic, const char *filter_expression, const DDS::StringSeq &expression_parameters, DomainParticipantImpl *participant)
virtual ~ContentFilteredTopicImpl ()
char * get_filter_expression ()
DDS::ReturnCode_t get_expression_parameters (DDS::StringSeq &parameters)
DDS::ReturnCode_t set_expression_parameters (const DDS::StringSeq &parameters)
DDS::Topic_ptr get_related_topic ()
template<typename Sample>
bool filter (const Sample &s) const
void add_reader (DataReaderImpl &reader)
void remove_reader (DataReaderImpl &reader)
const char * get_filter_class_name () const

Private Member Functions

 OPENDDS_VECTOR (DataReaderImpl *) readers_

Private Attributes

OPENDDS_STRING filter_expression_
FilterEvaluator filter_eval_
DDS::StringSeq expression_parameters_
DDS::Topic_var related_topic_
ACE_Recursive_Thread_Mutex lock_
 Concurrent access to expression_parameters_ and readers_.

Detailed Description

Definition at line 26 of file ContentFilteredTopicImpl.h.


Constructor & Destructor Documentation

OpenDDS::DCPS::ContentFilteredTopicImpl::ContentFilteredTopicImpl ( const char *  name,
DDS::Topic_ptr  related_topic,
const char *  filter_expression,
const DDS::StringSeq expression_parameters,
DomainParticipantImpl participant 
)

Definition at line 19 of file ContentFilteredTopicImpl.cpp.

00023   : TopicDescriptionImpl(name,
00024       CORBA::String_var(related_topic->get_type_name()),
00025       dynamic_cast<TopicDescriptionImpl*>(related_topic)->get_type_support(),
00026       participant)
00027   , filter_expression_(filter_expression)
00028   , filter_eval_(filter_expression, false /*allowOrderBy*/)
00029   , expression_parameters_(expression_parameters)
00030   , related_topic_(DDS::Topic::_duplicate(related_topic))
00031 {}

virtual OpenDDS::DCPS::ContentFilteredTopicImpl::~ContentFilteredTopicImpl (  )  [inline, virtual]

Definition at line 34 of file ContentFilteredTopicImpl.h.

00034 {}


Member Function Documentation

void OpenDDS::DCPS::ContentFilteredTopicImpl::add_reader ( DataReaderImpl reader  ) 

Definition at line 93 of file ContentFilteredTopicImpl.cpp.

References lock_.

Referenced by OpenDDS::DCPS::DataReaderImpl::enable_filtering().

00094 {
00095   // readers_ does not own or reference-count the reader because
00096   // the readers reference this CFT and this CFT can't be removed
00097   // until all readers are gone (DomainParticipant::delete_contentfilteredtopic)
00098   ACE_GUARD(ACE_Recursive_Thread_Mutex, guard, lock_);
00099   readers_.push_back(&reader);
00100 }

template<typename Sample>
bool OpenDDS::DCPS::ContentFilteredTopicImpl::filter ( const Sample &  s  )  const [inline]

Definition at line 45 of file ContentFilteredTopicImpl.h.

00046   {
00047     ACE_GUARD_RETURN(ACE_Recursive_Thread_Mutex, guard, lock_, false);
00048     return filter_eval_.eval(s, expression_parameters_);
00049   }

DDS::ReturnCode_t OpenDDS::DCPS::ContentFilteredTopicImpl::get_expression_parameters ( DDS::StringSeq parameters  ) 

Definition at line 39 of file ContentFilteredTopicImpl.cpp.

References expression_parameters_, lock_, DDS::RETCODE_OK, and DDS::RETCODE_OUT_OF_RESOURCES.

00040 {
00041   ACE_GUARD_RETURN(ACE_Recursive_Thread_Mutex, guard, lock_,
00042     DDS::RETCODE_OUT_OF_RESOURCES);
00043   params = expression_parameters_;
00044   return DDS::RETCODE_OK;
00045 }

const char* OpenDDS::DCPS::ContentFilteredTopicImpl::get_filter_class_name (  )  const [inline]

Definition at line 54 of file ContentFilteredTopicImpl.h.

Referenced by OpenDDS::DCPS::DataReaderImpl::enable().

00055   {
00056     return filter_eval_.usesExtendedGrammar () ? "OPENDDSSQL" : "DDSSQL";
00057   }

char * OpenDDS::DCPS::ContentFilteredTopicImpl::get_filter_expression (  ) 

Implements DDS::ContentFilteredTopic.

Definition at line 33 of file ContentFilteredTopicImpl.cpp.

References filter_expression_, and CORBA::string_dup().

00034 {
00035   return CORBA::string_dup(filter_expression_.c_str());
00036 }

DDS::Topic_ptr OpenDDS::DCPS::ContentFilteredTopicImpl::get_related_topic (  ) 

Implements DDS::ContentFilteredTopic.

Definition at line 87 of file ContentFilteredTopicImpl.cpp.

References related_topic_.

00088 {
00089   return DDS::Topic::_duplicate(related_topic_);
00090 }

OpenDDS::DCPS::ContentFilteredTopicImpl::OPENDDS_VECTOR ( DataReaderImpl  )  [private]

void OpenDDS::DCPS::ContentFilteredTopicImpl::remove_reader ( DataReaderImpl reader  ) 

Definition at line 103 of file ContentFilteredTopicImpl.cpp.

References lock_, and OpenDDS::DCPS::remove().

Referenced by OpenDDS::DCPS::DataReaderImpl::cleanup().

00104 {
00105   ACE_GUARD(ACE_Recursive_Thread_Mutex, guard, lock_);
00106   std::vector<DataReaderImpl*>::iterator end = readers_.end();
00107   readers_.erase(std::remove(readers_.begin(), end, &reader), end);
00108 }

DDS::ReturnCode_t OpenDDS::DCPS::ContentFilteredTopicImpl::set_expression_parameters ( const DDS::StringSeq parameters  ) 

Definition at line 54 of file ContentFilteredTopicImpl.cpp.

References expression_parameters_, lock_, DDS::RETCODE_OK, DDS::RETCODE_OUT_OF_RESOURCES, and OpenDDS::DCPS::string_equal().

00055 {
00056   ACE_GUARD_RETURN(ACE_Recursive_Thread_Mutex, guard, lock_,
00057     DDS::RETCODE_OUT_OF_RESOURCES);
00058 
00059   const CORBA::ULong len = p.length();
00060   if (len == expression_parameters_.length()) {
00061     const char* const* p_buf = p.get_buffer();
00062     char* const* e_buf = expression_parameters_.get_buffer();
00063 #ifdef _MSC_VER
00064 #pragma warning(push)
00065 #pragma warning(disable : 4996)
00066 #endif
00067     if (std::equal(&p_buf[0], &p_buf[len], &e_buf[0], string_equal)) {
00068       // no change, bail out now to avoid remote InfoRepo calls
00069       return DDS::RETCODE_OK;
00070     }
00071 #ifdef _MSC_VER
00072 #pragma warning(pop)
00073 #endif
00074   }
00075 
00076   expression_parameters_ = p;
00077 
00078   for (std::vector<DataReaderImpl*>::iterator iter = readers_.begin(),
00079        end = readers_.end(); iter != end; ++iter) {
00080     (*iter)->update_subscription_params(p);
00081   }
00082 
00083   return DDS::RETCODE_OK;
00084 }


Member Data Documentation

DDS::StringSeq OpenDDS::DCPS::ContentFilteredTopicImpl::expression_parameters_ [private]

Definition at line 62 of file ContentFilteredTopicImpl.h.

Referenced by get_expression_parameters(), and set_expression_parameters().

FilterEvaluator OpenDDS::DCPS::ContentFilteredTopicImpl::filter_eval_ [private]

Definition at line 61 of file ContentFilteredTopicImpl.h.

OPENDDS_STRING OpenDDS::DCPS::ContentFilteredTopicImpl::filter_expression_ [private]

Definition at line 60 of file ContentFilteredTopicImpl.h.

Referenced by get_filter_expression().

ACE_Recursive_Thread_Mutex OpenDDS::DCPS::ContentFilteredTopicImpl::lock_ [mutable, private]

Concurrent access to expression_parameters_ and readers_.

Definition at line 67 of file ContentFilteredTopicImpl.h.

Referenced by add_reader(), get_expression_parameters(), remove_reader(), and set_expression_parameters().

DDS::Topic_var OpenDDS::DCPS::ContentFilteredTopicImpl::related_topic_ [private]

Definition at line 63 of file ContentFilteredTopicImpl.h.

Referenced by get_related_topic().


The documentation for this class was generated from the following files:
Generated on Fri Feb 12 20:06:11 2016 for OpenDDS by  doxygen 1.4.7