SubscriptionInstance.h

Go to the documentation of this file.
00001 /*
00002  *
00003  *
00004  * Distributed under the OpenDDS License.
00005  * See: http://www.opendds.org/license.html
00006  */
00007 
00008 #ifndef OPENDDS_DCPS_SUBSCRIPTION_INSTANCE_H
00009 #define OPENDDS_DCPS_SUBSCRIPTION_INSTANCE_H
00010 
00011 #include "ace/OS_Memory.h"
00012 
00013 #include "dds/DdsDcpsInfrastructureC.h"
00014 
00015 #include "dcps_export.h"
00016 #include "ReceivedDataElementList.h"
00017 #include "ReceivedDataStrategy.h"
00018 #include "InstanceState.h"
00019 #include "PoolAllocationBase.h"
00020 #include "RcObject.h"
00021 #include "ace/Synch_Traits.h"
00022 
00023 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00024 #pragma once
00025 #endif /* ACE_LACKS_PRAGMA_ONCE */
00026 
00027 OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL
00028 
00029 namespace OpenDDS {
00030 namespace DCPS {
00031 
00032 class DataReaderImpl;
00033 
00034 /**
00035   * @class SubscriptionInstance
00036   *
00037   * @brief Struct that has information about an instance and the instance
00038   *        sample list.
00039   */
00040 class SubscriptionInstance : public RcObject {
00041 public:
00042   SubscriptionInstance(DataReaderImpl *reader,
00043                        const DDS::DataReaderQos& qos,
00044                        ACE_Recursive_Thread_Mutex& lock,
00045                        DDS::InstanceHandle_t handle)
00046     : instance_state_(reader, lock, handle),
00047       last_sequence_(),
00048       rcvd_samples_(&instance_state_),
00049       instance_handle_(handle),
00050       deadline_timer_id_(-1)
00051   {
00052     switch (qos.destination_order.kind) {
00053     case DDS::BY_RECEPTION_TIMESTAMP_DESTINATIONORDER_QOS:
00054       this->rcvd_strategy_.reset(new ReceptionDataStrategy(this->rcvd_samples_));
00055       break;
00056 
00057     case DDS::BY_SOURCE_TIMESTAMP_DESTINATIONORDER_QOS:
00058       this->rcvd_strategy_.reset(new SourceDataStrategy(this->rcvd_samples_));
00059       break;
00060     }
00061 
00062     if (!this->rcvd_strategy_) {
00063       ACE_ERROR((LM_ERROR,
00064                  ACE_TEXT("(%P|%t) ERROR: SubscriptionInstance: ")
00065                  ACE_TEXT(" unable to allocate ReceiveDataStrategy!\n")));
00066     }
00067   }
00068 
00069   /// Instance state for this instance
00070   InstanceState instance_state_ ;
00071 
00072   /// Sequence number of the move recent data sample received
00073   SequenceNumber last_sequence_ ;
00074 
00075   /// Data sample(s) in this instance
00076   ReceivedDataElementList rcvd_samples_ ;
00077 
00078   /// ReceivedDataElementList strategy
00079   unique_ptr<ReceivedDataStrategy> rcvd_strategy_;
00080 
00081   /// The instance handle for the registered object
00082   DDS::InstanceHandle_t instance_handle_;
00083 
00084   ACE_Time_Value   last_sample_tv_;
00085 
00086   ACE_Time_Value   cur_sample_tv_;
00087 
00088   long             deadline_timer_id_;
00089 
00090   ACE_Time_Value   last_accepted_;
00091 };
00092 
00093 typedef RcHandle<SubscriptionInstance> SubscriptionInstance_rch;
00094 
00095 } // namespace DCPS
00096 } // namespace OpenDDS
00097 
00098 OPENDDS_END_VERSIONED_NAMESPACE_DECL
00099 
00100 #endif /* OPENDDS_DCPS_SUBSCRIPTION_INSTANCE_H */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 10 Aug 2018 for OpenDDS by  doxygen 1.6.1