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, 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

typedef OPENDDS_VECTOR (WeakRcHandle< DataReaderImpl >) Readers

Private Attributes

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

Detailed Description

Definition at line 28 of file ContentFilteredTopicImpl.h.


Constructor & Destructor Documentation

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

Definition at line 21 of file ContentFilteredTopicImpl.cpp.

References _duplicate(), ACE_TEXT(), OpenDDS::DCPS::DCPS_debug_level, filter_eval_, LM_DEBUG, and OpenDDS::DCPS::FilterEvaluator::number_parameters().

00024   : TopicDescriptionImpl(name,
00025       CORBA::String_var(related_topic->get_type_name()),
00026       dynamic_cast<TopicDescriptionImpl*>(related_topic)->get_type_support(),
00027       participant)
00028   , filter_expression_(filter_expression)
00029   , filter_eval_(filter_expression, false /*allowOrderBy*/)
00030   , related_topic_(DDS::Topic::_duplicate(related_topic))
00031 {
00032   if (DCPS_debug_level > 5) {
00033     ACE_DEBUG((LM_DEBUG,
00034       ACE_TEXT("(%P|%t) ContentFilteredTopicImpl::ContentFilteredTopicImpl() - ")
00035       ACE_TEXT("Creating cft with filter <%C> which requires <%d> parameters\n"),
00036       filter_expression, filter_eval_.number_parameters()));
00037   }
00038 }

Here is the call graph for this function:

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

Definition at line 35 of file ContentFilteredTopicImpl.h.

00035 {}


Member Function Documentation

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

Definition at line 124 of file ContentFilteredTopicImpl.cpp.

References lock_, and readers_.

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

00125 {
00126   // readers_ does not own or reference-count the reader because
00127   // the readers reference this CFT and this CFT can't be removed
00128   // until all readers are gone (DomainParticipant::delete_contentfilteredtopic)
00129   ACE_GUARD(ACE_Recursive_Thread_Mutex, guard, lock_);
00130   readers_.push_back(reader);
00131 }

Here is the caller graph for this function:

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

Definition at line 46 of file ContentFilteredTopicImpl.h.

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

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

Definition at line 46 of file ContentFilteredTopicImpl.cpp.

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

00047 {
00048   ACE_GUARD_RETURN(ACE_Recursive_Thread_Mutex, guard, lock_,
00049     DDS::RETCODE_OUT_OF_RESOURCES);
00050   params = expression_parameters_;
00051   return DDS::RETCODE_OK;
00052 }

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

Definition at line 55 of file ContentFilteredTopicImpl.h.

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

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

Implements DDS::ContentFilteredTopic.

Definition at line 40 of file ContentFilteredTopicImpl.cpp.

References filter_expression_, and FACE::string_dup().

00041 {
00042   return CORBA::string_dup(filter_expression_.c_str());
00043 }

Here is the call graph for this function:

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

Implements DDS::ContentFilteredTopic.

Definition at line 118 of file ContentFilteredTopicImpl.cpp.

References CORBA::LocalObject::_duplicate(), and related_topic_.

Referenced by OpenDDS::DCPS::SubscriberImpl::create_datareader().

00119 {
00120   return DDS::Topic::_duplicate(related_topic_);
00121 }

Here is the call graph for this function:

Here is the caller graph for this function:

typedef OpenDDS::DCPS::ContentFilteredTopicImpl::OPENDDS_VECTOR ( WeakRcHandle< DataReaderImpl  )  [private]
void OpenDDS::DCPS::ContentFilteredTopicImpl::remove_reader ( DataReaderImpl reader  ) 

Definition at line 134 of file ContentFilteredTopicImpl.cpp.

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

00135 {
00136   ACE_GUARD(ACE_Recursive_Thread_Mutex, guard, lock_);
00137   Readers::iterator end = readers_.end();
00138   readers_.erase(std::remove(readers_.begin(), end, reader), end);
00139 }

Here is the call graph for this function:

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

Definition at line 61 of file ContentFilteredTopicImpl.cpp.

References ACE_TEXT(), OpenDDS::DCPS::DCPS_debug_level, expression_parameters_, filter_eval_, len, LM_ERROR, lock_, OpenDDS::DCPS::FilterEvaluator::number_parameters(), readers_, DDS::RETCODE_ERROR, DDS::RETCODE_OK, DDS::RETCODE_OUT_OF_RESOURCES, and OpenDDS::DCPS::swap().

00062 {
00063   ACE_GUARD_RETURN(ACE_Recursive_Thread_Mutex, guard, lock_,
00064     DDS::RETCODE_OUT_OF_RESOURCES);
00065 
00066   const CORBA::ULong len = p.length();
00067 
00068   // Check sequence of strings that give values to the 'parameters' (i.e., "%n" tokens)
00069   // in the filter_expression matches the size of the parameter sequence.
00070   // The tokens start with 0 which means that when the maximum number used is 1 we need
00071   // two parameters: %0 and %1
00072   if (len != filter_eval_.number_parameters()) {
00073     if (DCPS_debug_level > 1) {
00074         ACE_ERROR((LM_ERROR,
00075           ACE_TEXT("(%P|%t) ContentFilteredTopicImpl::set_expression_parameters() - ")
00076           ACE_TEXT("passed incorrect set of filter parameters, expected %d received %d\n"),
00077           filter_eval_.number_parameters(), len));
00078     }
00079     return DDS::RETCODE_ERROR;
00080   }
00081 
00082   if (len == expression_parameters_.length()) {
00083     const char* const* p_buf = p.get_buffer();
00084     char* const* e_buf = expression_parameters_.get_buffer();
00085 #ifdef _MSC_VER
00086 #pragma warning(push)
00087 #pragma warning(disable : 4996)
00088 #endif
00089     if (std::equal(&p_buf[0], &p_buf[len], &e_buf[0], string_equal)) {
00090       // no change, bail out now to avoid remote InfoRepo calls
00091       return DDS::RETCODE_OK;
00092     }
00093 #ifdef _MSC_VER
00094 #pragma warning(pop)
00095 #endif
00096   }
00097 
00098   expression_parameters_ = p;
00099 
00100   Readers readers_still_alive;
00101 
00102   for (Readers::iterator iter = readers_.begin(),
00103        end = readers_.end(); iter != end; ++iter) {
00104     DataReaderImpl_rch reader = iter->lock();
00105     if (reader) {
00106       reader->update_subscription_params(p);
00107       readers_still_alive.push_back(*iter);
00108     }
00109   }
00110 
00111   using namespace std;
00112   swap(readers_, readers_still_alive);
00113 
00114   return DDS::RETCODE_OK;
00115 }

Here is the call graph for this function:


Member Data Documentation

Definition at line 61 of file ContentFilteredTopicImpl.h.

Referenced by get_filter_expression().

Concurrent access to expression_parameters_ and readers_.

Definition at line 69 of file ContentFilteredTopicImpl.h.

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

Definition at line 66 of file ContentFilteredTopicImpl.h.

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

Definition at line 64 of file ContentFilteredTopicImpl.h.

Referenced by get_related_topic().


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 10 Aug 2018 for OpenDDS by  doxygen 1.6.1