TAO_TIO Class Reference

Time Interval Object Implementation. More...

#include <TAO_TIO.h>

List of all members.

Public Member Functions

 TAO_TIO (TimeBase::TimeT lower, TimeBase::TimeT upper)
 Constructor.
 ~TAO_TIO (void)
 Destructor.
virtual TimeBase::IntervalT time_interval ()
 This is the get method for the attribute time interval.
virtual CosTime::OverlapType spans (CosTime::UTO_ptr time, CosTime::TIO_out overlap)
virtual CosTime::OverlapType overlaps (CosTime::TIO_ptr interval, CosTime::TIO_out overlap)
virtual CosTime::UTO_ptr time (void)

Private Attributes

TimeBase::IntervalT attr_time_interval


Detailed Description

Time Interval Object Implementation.

The TIO represents a time interval and has operations to compare itself with a UTO or another TIO. It also has an operation to create a UTO from the value of it's time interval.

Definition at line 37 of file TAO_TIO.h.


Constructor & Destructor Documentation

TAO_BEGIN_VERSIONED_NAMESPACE_DECL TAO_TIO::TAO_TIO ( TimeBase::TimeT  lower,
TimeBase::TimeT  upper 
)

Constructor.

Definition at line 8 of file TAO_TIO.cpp.

References attr_time_interval.

00010 {
00011   this->attr_time_interval.lower_bound = lower;
00012   this->attr_time_interval.upper_bound = upper;
00013 }

TAO_TIO::~TAO_TIO ( void   ) 

Destructor.

Definition at line 16 of file TAO_TIO.cpp.

00017 {
00018 }


Member Function Documentation

CosTime::OverlapType TAO_TIO::overlaps ( CosTime::TIO_ptr  interval,
CosTime::TIO_out  overlap 
) [virtual]

This operation returns a value of type OverlapType depending on how the interval in the object and interval in the parameter TIO overlap. If OverlapType is not OTNoOverlap, then the out parameter overlap contains the overlap interval, otherwise the out parameter contains the gap between the two intervals.

Definition at line 147 of file TAO_TIO.cpp.

References ACE_NEW_THROW_EX, CosTime::OTContained, CosTime::OTNoOverlap, CosTime::OTOverlap, and time_interval().

00149 {
00150   TAO_TIO *tio_i = 0;
00151 
00152   TimeBase::TimeT lb1 =
00153     this->time_interval ().lower_bound;
00154 
00155   TimeBase::TimeT up1 =
00156     this->time_interval ().upper_bound;
00157 
00158   TimeBase::TimeT lb2 =
00159     tio->time_interval ().lower_bound;
00160 
00161   TimeBase::TimeT up2 =
00162     tio->time_interval ().upper_bound;
00163 
00164   if (lb1 == lb2 && up1 == up2)
00165     {
00166       ACE_NEW_THROW_EX (tio_i,
00167                         TAO_TIO (lb1, up1),
00168                         CORBA::NO_MEMORY ());
00169 
00170 
00171       overlap = tio_i->_this ();
00172 
00173       return CosTime::OTOverlap;
00174     }
00175   else if (lb1 > lb2 && up1 < up2)
00176     {
00177       ACE_NEW_THROW_EX (tio_i,
00178                         TAO_TIO (lb1, up1),
00179                         CORBA::NO_MEMORY ());
00180 
00181       overlap = tio_i->_this ();
00182 
00183       return CosTime::OTContained;
00184     }
00185   else if (lb1 < lb2 && up1 > up2)
00186     {
00187       ACE_NEW_THROW_EX (tio_i,
00188                         TAO_TIO (lb2, up2),
00189                         CORBA::NO_MEMORY ());
00190 
00191       overlap = tio_i->_this ();
00192 
00193       return CosTime::OTContained;
00194     }
00195   else if (lb1 < lb2)
00196     {
00197       if (up1 < lb2)
00198         {
00199           ACE_NEW_THROW_EX (tio_i,
00200                             TAO_TIO (0, 0),
00201                             CORBA::NO_MEMORY ());
00202           overlap = tio_i->_this ();
00203 
00204           return CosTime::OTNoOverlap;
00205         }
00206       else
00207         {
00208           ACE_NEW_THROW_EX (tio_i,
00209                             TAO_TIO (lb2, up1),
00210                             CORBA::NO_MEMORY ());
00211 
00212           overlap = tio_i->_this ();
00213 
00214           return CosTime::OTOverlap;
00215         }
00216     }
00217   else if (up2 < lb1)
00218     {
00219       ACE_NEW_THROW_EX (tio_i,
00220                         TAO_TIO (0, 0),
00221                         CORBA::NO_MEMORY ());
00222 
00223       overlap = tio_i->_this ();
00224 
00225       return CosTime::OTNoOverlap;
00226     }
00227   else
00228     {
00229       ACE_NEW_THROW_EX (tio_i,
00230                         TAO_TIO (lb1, up2),
00231                         CORBA::NO_MEMORY ());
00232       overlap = tio_i->_this ();
00233     }
00234 
00235   return CosTime::OTNoOverlap;
00236 }

CosTime::OverlapType TAO_TIO::spans ( CosTime::UTO_ptr  time,
CosTime::TIO_out  overlap 
) [virtual]

This operation returns a value of type OverlapType depending on how the interval in the object and the time range represented by the parameter UTO overlap. If OverlapType is not OTNoOverlap, then the out parameter overlap contains the overlap interval, otherwise the out parameter contains the gap between the two intervals.

Definition at line 35 of file TAO_TIO.cpp.

References CORBA::Exception::_tao_print_exception(), ACE_NEW_RETURN, CosTime::OTContained, CosTime::OTNoOverlap, CosTime::OTOverlap, and time_interval().

00037 {
00038   TAO_TIO *tio = 0;
00039 
00040   try
00041     {
00042       TimeBase::TimeT lb1 =
00043         this->time_interval ().lower_bound;
00044 
00045       TimeBase::TimeT up1 =
00046         this->time_interval ().upper_bound;
00047 
00048       TimeBase::TimeT tmp1 = uto->time ();
00049 
00050       TimeBase::TimeT tmp2 = uto->inaccuracy ();
00051 
00052       TimeBase::TimeT lb2 = tmp1 - tmp2;
00053 
00054 
00055       tmp1 = uto->time ();
00056 
00057       tmp2 = uto->inaccuracy ();
00058 
00059       TimeBase::TimeT up2 = tmp1 + tmp2;
00060 
00061       if (lb1 == lb2 && up1 == up2)
00062         {
00063           ACE_NEW_RETURN (tio,
00064                           TAO_TIO (lb1, up1),
00065                           CosTime::OTNoOverlap);
00066           overlap = tio->_this ();
00067 
00068           return CosTime::OTOverlap;
00069         }
00070       else if (lb1 > lb2 && up1 < up2)
00071         {
00072           ACE_NEW_RETURN (tio,
00073                           TAO_TIO (lb1, up1),
00074                           CosTime::OTNoOverlap);
00075 
00076           overlap = tio->_this ();
00077 
00078           return CosTime::OTContained;
00079         }
00080       else if (lb1 < lb2 && up1 > up2)
00081         {
00082           ACE_NEW_RETURN (tio,
00083                           TAO_TIO (lb2, up2),
00084                           CosTime::OTNoOverlap);
00085 
00086           overlap = tio->_this ();
00087 
00088           return CosTime::OTContained;
00089         }
00090       else if (lb1 < lb2)
00091         {
00092           if (up1 < lb2)
00093             {
00094               ACE_NEW_RETURN (tio,
00095                               TAO_TIO (0, 0),
00096                               CosTime::OTNoOverlap);
00097 
00098               overlap = tio->_this ();
00099 
00100               return CosTime::OTNoOverlap;
00101             }
00102           else
00103             {
00104               ACE_NEW_RETURN (tio,
00105                               TAO_TIO (lb2, up1),
00106                               CosTime::OTNoOverlap);
00107               overlap = tio->_this ();
00108 
00109               return CosTime::OTOverlap;
00110             }
00111         }
00112       else if (up2 < lb1)
00113         {
00114 
00115           ACE_NEW_RETURN (tio,
00116                           TAO_TIO (0, 0),
00117                           CosTime::OTNoOverlap);
00118 
00119           overlap = tio->_this ();
00120 
00121           return CosTime::OTNoOverlap;
00122         }
00123       else
00124         {
00125           ACE_NEW_RETURN (tio,
00126                           TAO_TIO (lb1, up2),
00127                           CosTime::OTNoOverlap);
00128 
00129           overlap = tio->_this ();
00130         }
00131     }
00132   catch (const CORBA::Exception& ex)
00133     {
00134       ex._tao_print_exception ("Exception:");
00135     }
00136 
00137   return CosTime::OTNoOverlap;
00138 }

CosTime::UTO_ptr TAO_TIO::time ( void   )  [virtual]

Returns a UTO in which the inaccuracy interval is equal to the time interval in the TIO and time value is the midpoint of the interval.

Definition at line 239 of file TAO_TIO.cpp.

References ACE_NEW_THROW_EX, and time_interval().

00240 {
00241   TAO_UTO *uto = 0;
00242 
00243   ACE_NEW_THROW_EX (uto,
00244                     TAO_UTO ((this->time_interval ().upper_bound -
00245                               this->time_interval ().lower_bound) / 2,
00246                              this->time_interval ().upper_bound -
00247                              this->time_interval ().lower_bound,
00248                              0),
00249                     CORBA::NO_MEMORY ());
00250 
00251 
00252   return uto->_this ();
00253 }

TimeBase::IntervalT TAO_TIO::time_interval (  )  [virtual]

This is the get method for the attribute time interval.

Definition at line 23 of file TAO_TIO.cpp.

References attr_time_interval.

Referenced by overlaps(), spans(), and time().

00024 {
00025   return attr_time_interval;
00026 }


Member Data Documentation

TimeBase::IntervalT TAO_TIO::attr_time_interval [private]

This attribute returns an IntervalT structure with the values of its fields filled in with the corresponding values from the TIO.

Definition at line 82 of file TAO_TIO.h.

Referenced by TAO_TIO(), and time_interval().


The documentation for this class was generated from the following files:
Generated on Tue Feb 2 17:49:18 2010 for TAO_CosTime by  doxygen 1.4.7