summaryrefslogtreecommitdiff
path: root/CIAO/connectors/dds4ccm/impl/Reader_T.h
blob: bde38f6ae7d29f7ee9c0372189311c2966fcc9be (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/**
 * @author William R. Otte <wotte@dre.vanderbilt.edu>
 * @author Johnny Willemsen (jwillemsen@remedy.nl)
 *
 * Wrapper facade for NDDS.
 */
#ifndef READER_T_H_
#define READER_T_H_

#include "dds4ccm/idl/ccm_ddsC.h"
#include "ace/Copy_Disabled.h"
#include "dds4ccm/impl/dds4ccm_conf.h"
#include "dds4ccm/impl/LocalObject.h"

namespace CIAO
{
  namespace DDS4CCM
  {
    class ConditionManager;

    template <typename READER_TYPE, typename TYPED_DDS_READER, typename VALUE_TYPE, typename SEQ_VALUE_TYPE>
    class Reader_T :
        public virtual READER_TYPE,
        public virtual LocalObject,
        private virtual ACE_Copy_Disabled
    {
    public:
      /// Constructor
      Reader_T (void);

      /// Destructor
      virtual ~Reader_T (void);

      virtual void read_last (
        SEQ_VALUE_TYPE& instances,
        ::CCM_DDS::ReadInfoSeq& infos);

      virtual void read_all (
        SEQ_VALUE_TYPE& instances,
        ::CCM_DDS::ReadInfoSeq& infos);

      virtual void read_one_last (
        VALUE_TYPE& an_instance,
        ::CCM_DDS::ReadInfo_out info,
        DDS_INSTANCE_HANDLE_T_IN instance_handle);

      virtual void read_one_all (
        const VALUE_TYPE& an_instance,
        SEQ_VALUE_TYPE& instances,
        ::CCM_DDS::ReadInfoSeq& infos,
        DDS_INSTANCE_HANDLE_T_IN instance_handle);

      virtual ::CCM_DDS::QueryFilter *query (void);

      virtual void query (const ::CCM_DDS::QueryFilter & filter);

      void set_dds_reader (::DDS::DataReader_ptr dr,
                           ::CIAO::DDS4CCM::ConditionManager * condition_manager);

      ::DDS::DataReader_ptr get_dds_reader (void);

    private:
      typename TYPED_DDS_READER::_var_type dds_reader_;
      ::CIAO::DDS4CCM::ConditionManager * condition_manager_;

      typename TYPED_DDS_READER::_ptr_type dds_reader (void);

      // Helper methods
      ::CORBA::ULong get_nr_valid_samples (
        const ::DDS::SampleInfoSeq& sample_infos,
        const bool determine_last);

      ::DDS::InstanceHandle_t check_handle (
        const VALUE_TYPE& an_instance,
        DDS_INSTANCE_HANDLE_T_IN instance_handle);

      void convert_data (
        const SEQ_VALUE_TYPE& all_data,
        SEQ_VALUE_TYPE& data_to_return,
        ::CCM_DDS::ReadInfoSeq& infos,
        const ::DDS::SampleInfoSeq & sample_info);

      void read_wo_instance (
        SEQ_VALUE_TYPE& data,
        ::DDS::SampleInfoSeq & sample_info,
        ::DDS::QueryCondition_ptr qc);

      void read_w_instance (
        SEQ_VALUE_TYPE& data,
        ::DDS::SampleInfoSeq & sample_info,
        DDS_INSTANCE_HANDLE_T_IN lookup_hnd);

      void return_loan (
        SEQ_VALUE_TYPE& data,
        ::DDS::SampleInfoSeq sample_info,
        bool throw_exception=true);
    };
  }
}

#include "dds4ccm/impl/Reader_T.cpp"

#endif /* READER_T_H_ */