summaryrefslogtreecommitdiff
path: root/CIAO/connectors/dds4ccm/impl/Getter_T.h
blob: cbc88713b5d6e9ab2af1cd5ee0f6aeb01c24f2ea (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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
/**
 * @author Marcel Smit <msmit@remedy.nl>
 *
 * $Id$
 *
 * Wrapper facade for NDDS.
 */

#ifndef GETTER_T_H_
#define GETTER_T_H_

#include "dds4ccm/idl/dds_rtf2_dcpsC.h"
#include "ace/Copy_Disabled.h"

#if (CIAO_DDS4CCM_OPENDDS==1)
typedef ::DDS::GuardCondition DDSGuardCondition;
typedef ::DDS::WaitSet DDSWaitSet;
typedef ::DDS::ReadCondition DDSReadCondition;
typedef ::DDS::ConditionSeq DDSConditionSeq;
#endif

namespace CIAO
{
  namespace DDS4CCM
  {
    namespace DDS_CCM
    {

      /**
      * @class Getter_Base_T<DDS_TYPE,CCM_TYPE>
      *
      * @brief Templated base class for the Getter port.
      *
      *        Spec:  Get operations are performed with the following parameters
      *                · SampleStateMask: NO_READ,
      *                · ViewStateMask: NEW or NOT_NEW,
      *                · InstanceStateMask: ALIVE or NOT_ALIVE,
      *               · Through the query (if any) of the Reader associated to the port,
      *                · Within the time limit specified in time_out.
      *
      *               All methods return a boolean as result indicating whether actual data
      *               are provided (TRUE) or if the time-out occurred (FALSE).
      */
      template <typename DDS_TYPE, typename CCM_TYPE, DDS4CCM_Vendor VENDOR_TYPE>
      class Getter_Base_T :
         public virtual CCM_TYPE::getter_type,
         public virtual DDS4CCM_LocalObject_T<CCM_TYPE>,
         private virtual ACE_Copy_Disabled
      {
      typedef CIAO::DDS4CCM::CCM_DDS_ReadCondition_T<DDS_TYPE, CCM_TYPE, VENDOR_TYPE>
        ReadCondition_type;
      typedef CIAO::DDS4CCM::DataReader_T<DDS_TYPE, CCM_TYPE, VENDOR_TYPE>
        DataReader_type;
      typedef CIAO::DDS4CCM::ConditionManager_T<DDS_TYPE, CCM_TYPE, VENDOR_TYPE>
        ConditionManager_type;

      public:
        /// Constructor
        Getter_Base_T (void);

        /// Destructor
        virtual ~Getter_Base_T (void);

        /**
         *  Spec : get_many returns all the available samples
         *         in the limits set by the attribute max_delivered_data.
         *         In case there are more available samples, the first
         *         max_delivered_data are returned. The default value for
         *         that attribute is UNLIMITED (0)
         */
        virtual bool get_many (
          typename CCM_TYPE::seq_type& instances,
          ::CCM_DDS::ReadInfoSeq& infos);

        /**
         * @name time_out
         * Accessors for time_out
         */
        //@{
        virtual ::DDS::Duration_t time_out (void);
        virtual void time_out (const ::DDS::Duration_t & time_out);
        //@}

        /**
         * @name max_delivered_data
         * Accessors for max_delivered_data
         */
        //@{
        virtual ::CCM_DDS::DataNumber_t max_delivered_data (void);
        virtual void max_delivered_data (
          ::CCM_DDS::DataNumber_t max_delivered_data);
        //@}

        /**
         * Set the actual pointer to DDS Datareader
         */
        void set_impl (DataReader_type * reader,
                       ConditionManager_type * condition_manager);
      protected:
        DataReader_type * reader_;
        ConditionManager_type * condition_manager_;


        ::DDS_Duration_t time_out_;
        ::CCM_DDS::DataNumber_t max_delivered_data_;

        DataReader_type * impl (void);

        ::DDS::ReturnCode_t get (typename DDS_TYPE::dds_seq_type & data,
                                 DDS_SampleInfoSeq & sample_info,
                                 const DDS_Long & max_samples);
      };

      template <typename DDS_TYPE, typename CCM_TYPE, bool FIXED, DDS4CCM_Vendor VENDOR_TYPE>
      class Getter_T;

      /**
      * @brief Implementation of the Getter port for variable sized data types.
      *
      */
      template <typename DDS_TYPE, typename CCM_TYPE, DDS4CCM_Vendor VENDOR_TYPE>
      class Getter_T <DDS_TYPE, CCM_TYPE, false, VENDOR_TYPE> :
        public Getter_Base_T <DDS_TYPE, CCM_TYPE, VENDOR_TYPE>
      {
      public:
        /**
        *
        * @brief  get_one implementation for variable sized datatypes.
        *
        *         Spec : get_one returns the next sample to be gotten.
        */
        virtual bool get_one (
          typename DDS_TYPE::value_type::_out_type an_instance,
          ::CCM_DDS::ReadInfo_out info);
      };

      /**
      * @brief Implementation of the Getter port for fixed sized data types.
      *
      */
      template <typename DDS_TYPE, typename CCM_TYPE, DDS4CCM_Vendor VENDOR_TYPE>
      class Getter_T <DDS_TYPE, CCM_TYPE, true, VENDOR_TYPE> :
        public Getter_Base_T <DDS_TYPE, CCM_TYPE, VENDOR_TYPE>
      {
      public:
        /**
        * @brief  get_one implementation for fixed sized datatypes.
        *
        *         Spec : get_one returns the next sample to be gotten.
        */
        virtual bool get_one (
          typename DDS_TYPE::value_type::_out_type an_instance,
          ::CCM_DDS::ReadInfo_out info);
      };
    }
  }
}

#include "dds4ccm/impl/Getter_T.cpp"

#endif /* GETTER_T_H_ */