00001
00002
00003
00004
00005
00006
00007
00008 #ifndef OPENDDS_DCPS_QUERYCONDITIONIMPL_H
00009 #define OPENDDS_DCPS_QUERYCONDITIONIMPL_H
00010
00011 #ifndef OPENDDS_NO_QUERY_CONDITION
00012
00013 #include "dds/DdsDcpsSubscriptionC.h"
00014 #include "dds/DCPS/ReadConditionImpl.h"
00015 #include "dds/DCPS/FilterEvaluator.h"
00016 #include "dds/DCPS/PoolAllocator.h"
00017
00018 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00019 #pragma once
00020 #endif
00021
00022 #include <vector>
00023
00024 namespace OpenDDS {
00025 namespace DCPS {
00026
00027 class DataReaderImpl;
00028
00029 class OpenDDS_Dcps_Export QueryConditionImpl
00030 : public virtual OpenDDS::DCPS::LocalObject<DDS::QueryCondition>
00031 , public virtual ReadConditionImpl {
00032 public:
00033 QueryConditionImpl(DataReaderImpl* dr, DDS::SampleStateMask sample_states,
00034 DDS::ViewStateMask view_states, DDS::InstanceStateMask instance_states,
00035 const char* query_expression, const DDS::StringSeq& query_parameters)
00036 : ReadConditionImpl(dr, sample_states, view_states, instance_states)
00037 , query_expression_(query_expression)
00038 , query_parameters_(query_parameters)
00039 , evaluator_(query_expression, true) {}
00040
00041 virtual ~QueryConditionImpl() {}
00042
00043 char* get_query_expression();
00044
00045 DDS::ReturnCode_t get_query_parameters(DDS::StringSeq& query_parameters);
00046
00047 DDS::ReturnCode_t set_query_parameters(
00048 const DDS::StringSeq& query_parameters);
00049
00050 CORBA::Boolean get_trigger_value();
00051
00052 std::vector<OPENDDS_STRING> getOrderBys() const;
00053
00054 bool hasFilter() const;
00055
00056 template<typename Sample>
00057 bool filter(const Sample& s) const
00058 {
00059 ACE_GUARD_RETURN(ACE_Recursive_Thread_Mutex, guard, lock_, false);
00060 return evaluator_.eval(s, query_parameters_);
00061 }
00062
00063 private:
00064 CORBA::String_var query_expression_;
00065 DDS::StringSeq query_parameters_;
00066 FilterEvaluator evaluator_;
00067 mutable ACE_Recursive_Thread_Mutex lock_;
00068 };
00069
00070 }
00071 }
00072
00073 #endif // OPENDDS_NO_QUERY_CONDITION
00074
00075 #endif