LCOV - code coverage report
Current view: top level - DCPS - QueryConditionImpl.h (source / functions) Hit Total Coverage
Test: coverage.info Lines: 0 10 0.0 %
Date: 2023-04-30 01:32:43 Functions: 0 56 0.0 %

          Line data    Source code
       1             : /*
       2             :  *
       3             :  *
       4             :  * Distributed under the OpenDDS License.
       5             :  * See: http://www.opendds.org/license.html
       6             :  */
       7             : 
       8             : #ifndef OPENDDS_DCPS_QUERYCONDITIONIMPL_H
       9             : #define OPENDDS_DCPS_QUERYCONDITIONIMPL_H
      10             : 
      11             : #ifndef OPENDDS_NO_QUERY_CONDITION
      12             : 
      13             : #include "dds/DdsDcpsSubscriptionC.h"
      14             : #include "ReadConditionImpl.h"
      15             : #include "FilterEvaluator.h"
      16             : #include "PoolAllocator.h"
      17             : 
      18             : #if !defined (ACE_LACKS_PRAGMA_ONCE)
      19             : #pragma once
      20             : #endif /* ACE_LACKS_PRAGMA_ONCE */
      21             : 
      22             : #include <vector>
      23             : 
      24             : OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL
      25             : 
      26             : namespace OpenDDS {
      27             : namespace DCPS {
      28             : 
      29             : class DataReaderImpl;
      30             : class TypeSupportImpl;
      31             : 
      32             : class OpenDDS_Dcps_Export QueryConditionImpl
      33             :   : public virtual OpenDDS::DCPS::LocalObject<DDS::QueryCondition>
      34             :   , public virtual ReadConditionImpl {
      35             : public:
      36             :   QueryConditionImpl(DataReaderImpl* dr, DDS::SampleStateMask sample_states,
      37             :                      DDS::ViewStateMask view_states, DDS::InstanceStateMask instance_states,
      38             :                      const char* query_expression);
      39             : 
      40           0 :   virtual ~QueryConditionImpl() {}
      41             : 
      42             :   char* get_query_expression();
      43             : 
      44             :   DDS::ReturnCode_t get_query_parameters(DDS::StringSeq& query_parameters);
      45             : 
      46             :   DDS::ReturnCode_t set_query_parameters(
      47             :     const DDS::StringSeq& query_parameters);
      48             : 
      49             :   CORBA::Boolean get_trigger_value();
      50             : 
      51             :   std::vector<OPENDDS_STRING> getOrderBys() const;
      52             : 
      53             :   bool hasFilter() const;
      54             : 
      55             :   /**
      56             :    * Returns true if the sample matches the query.
      57             :    */
      58             :   template<typename Sample>
      59           0 :   bool filter(const Sample& s, bool sample_only_has_key_fields) const
      60             :   {
      61           0 :     ACE_GUARD_RETURN(ACE_Recursive_Thread_Mutex, guard, lock_, false);
      62             :     /*
      63             :      * Omit the sample from results if the query references non-key fields
      64             :      * and the sample only has key fields.
      65             :      */
      66           0 :     TypeSupportImpl* const ts = get_type_support();
      67           0 :     if (!ts || (sample_only_has_key_fields && evaluator_.has_non_key_fields(*ts))) {
      68           0 :       if (DCPS_debug_level > 8) {
      69           0 :         ACE_DEBUG((LM_DEBUG,
      70             :           ACE_TEXT("(%P|%t) QueryConditionImpl::filter: ")
      71             :           ACE_TEXT("Sample has been filtered because the query ")
      72             :           ACE_TEXT("references fields that are not readable\n")
      73             :         ));
      74             :       }
      75           0 :       return false;
      76             :     }
      77           0 :     return evaluator_.eval(s, query_parameters_);
      78           0 :   }
      79             : 
      80             : private:
      81             :   TypeSupportImpl* get_type_support() const;
      82             : 
      83             :   CORBA::String_var query_expression_;
      84             :   DDS::StringSeq query_parameters_;
      85             :   FilterEvaluator evaluator_;
      86             :   /// Concurrent access to query_parameters_
      87             :   mutable ACE_Recursive_Thread_Mutex lock_;
      88             : };
      89             : 
      90             : } // namespace DCPS
      91             : } // namespace OpenDDS
      92             : 
      93             : OPENDDS_END_VERSIONED_NAMESPACE_DECL
      94             : 
      95             : #endif // OPENDDS_NO_QUERY_CONDITION
      96             : 
      97             : #endif

Generated by: LCOV version 1.16