Public Member Functions | Private Attributes

TAO_UTO Class Reference

Universal Time Object Implementation. More...

#include <TAO_UTO.h>

List of all members.

Public Member Functions

 TAO_UTO (TimeBase::TimeT time, TimeBase::InaccuracyT inaccuracy, TimeBase::TdfT tdf)
 Constructor.
 ~TAO_UTO (void)
 Destructor.
virtual TimeBase::TimeT time ()
 For the readonly attribute <time>.
virtual TimeBase::InaccuracyT inaccuracy (void)
 For the readonly attribute <inaccuracy>.
virtual TimeBase::TdfT tdf (void)
virtual TimeBase::UtcT utc_time (void)
 For the readonly attribute <utc_time>.
CosTime::UTO_ptr absolute_time (void)
CosTime::TimeComparison compare_time (CosTime::ComparisonType comparison_type, CosTime::UTO_ptr uto)
CosTime::TIO_ptr time_to_interval (CosTime::UTO_ptr)
CosTime::TIO_ptr interval (void)

Private Attributes

TimeBase::UtcT attr_utc_time_

Detailed Description

Universal Time Object Implementation.

This is an encapsulation of the time. It provides the following operations on basic time.

Definition at line 43 of file TAO_UTO.h.


Constructor & Destructor Documentation

TAO_UTO::TAO_UTO ( TimeBase::TimeT  time,
TimeBase::InaccuracyT  inaccuracy,
TimeBase::TdfT  tdf 
)

Constructor.

Definition at line 16 of file TAO_UTO.cpp.

{

  this->attr_utc_time_.time = time;

  // Extract the lower 32 bits in the inacclo.
  this->attr_utc_time_.inacclo = (CORBA::ULong) ACE_U64_TO_U32 (inaccuracy);

  // Extract the lower 16 bits of the remaining bits. 'And'ing with 0xFFFF
  // is only a sanity check.

#if defined (ACE_LACKS_U_LONGLONG_T)
  this->attr_utc_time_.inacchi = 0;
#else
  this->attr_utc_time_.inacchi =
    static_cast<CORBA::UShort> ((inaccuracy >> 32U) & 0xFFFF);

#endif /* ACE_LACKS_U_LONGLONG_T */

  this->attr_utc_time_.tdf = tdf;

}

TAO_UTO::~TAO_UTO ( void   ) 

Destructor.

Definition at line 43 of file TAO_UTO.cpp.

{
}


Member Function Documentation

CosTime::UTO_ptr TAO_UTO::absolute_time ( void   ) 

Absolute time = Relative time + Base time. ?? Find out more about the Base Time, UTC and Distributed Time Sync. Algos. [3

Definition at line 89 of file TAO_UTO.cpp.

{
  return CosTime::UTO::_nil ();
}

CosTime::TimeComparison TAO_UTO::compare_time ( CosTime::ComparisonType  comparison_type,
CosTime::UTO_ptr  uto 
)

Compares the time contained in the object with the time in the supplied uto according to the supplied comparison type.

Definition at line 98 of file TAO_UTO.cpp.

{
  TimeBase::TimeT uto_time = uto->time ();

  TimeBase::InaccuracyT this_inaccuracy =
    this->inaccuracy ();

  TimeBase::InaccuracyT uto_inaccuracy =
    uto->inaccuracy ();

  if (comparison_type == CosTime::MidC)
    {
      if (this->time () == uto_time)
        {
          return CosTime::TCEqualTo;
        }
      else if (this->time () > uto_time)
        {
          return CosTime::TCGreaterThan;
        }
      else
        return CosTime::TCLessThan;
    }
  else if (this->time () == uto_time)
    {
      if (this_inaccuracy == 0U
          && uto_inaccuracy  == 0U)
        {
          return CosTime::TCEqualTo;
        }
    }
  else
    {
      if (this->time () > uto_time)
        {
          if (this->time () - this_inaccuracy
              > uto_time  - uto_inaccuracy)
            {
              return CosTime::TCGreaterThan;
            }
        }
      else if (this->time () + this_inaccuracy
               < uto_time - uto_inaccuracy)
        {
          return CosTime::TCLessThan;
        }
    }

  return CosTime::TCIndeterminate;
}

TimeBase::InaccuracyT TAO_UTO::inaccuracy ( void   )  [virtual]

For the readonly attribute <inaccuracy>.

Definition at line 58 of file TAO_UTO.cpp.

{
  // Construct the Inaccuracy from the
  // inacchi and inacclo.

  TimeBase::InaccuracyT inaccuracy = attr_utc_time_.inacchi;
  inaccuracy <<= 32;
  inaccuracy |= attr_utc_time_.inacclo;
  return inaccuracy;
}

CosTime::TIO_ptr TAO_UTO::interval ( void   ) 

Returns a TIO object representing the error interval around the time value in the UTO.

Definition at line 195 of file TAO_UTO.cpp.

{
  TAO_TIO *tio = 0;

  try
    {
      TimeBase::TimeT this_inaccuracy =
          this->inaccuracy ();

      TimeBase::TimeT lower =
        this->time () - this_inaccuracy;

      TimeBase::TimeT upper =
        this->time () + this_inaccuracy;

      ACE_NEW_THROW_EX (tio,
                        TAO_TIO (lower,
                                 upper),
                        CORBA::NO_MEMORY ());
    }
  catch (const CORBA::Exception& ex)
    {
      ex._tao_print_exception ("Exception:");
      return CosTime::TIO::_nil ();
    }

  return tio->_this ();
}

TimeBase::TdfT TAO_UTO::tdf ( void   )  [virtual]

For the readonly attribute <tdf>, which is the "time displacement factor".

Definition at line 72 of file TAO_UTO.cpp.

{
  return attr_utc_time_.tdf;
}

TimeBase::TimeT TAO_UTO::time ( void   )  [virtual]

For the readonly attribute <time>.

Definition at line 50 of file TAO_UTO.cpp.

{
  return attr_utc_time_.time;
}

CosTime::TIO_ptr TAO_UTO::time_to_interval ( CosTime::UTO_ptr  uto  ) 

Returns a TIO representing the time interval between the time in the object and the time in the UTO passed as a parameter. The interval returned is the interval between the mid-points of the two UTOs. Inaccuracies are ignored. Note the result of this operation is meaningless if the base times of UTOs are different.

Definition at line 157 of file TAO_UTO.cpp.

{
  TAO_TIO *tio = 0;

  try
    {
      TimeBase::TimeT uto_time = uto->time ();

      if (this->time () > uto_time)
        {
          ACE_NEW_THROW_EX (tio,
                            TAO_TIO (uto_time,
                                     this->time ()),
                            CORBA::NO_MEMORY ());

        }
      else
        {
          ACE_NEW_THROW_EX (tio,
                            TAO_TIO (this->time (),
                                     uto_time),
                            CORBA::NO_MEMORY ());

        }
    }
  catch (const CORBA::Exception& ex)
    {
      ex._tao_print_exception ("Exception:");
      return CosTime::TIO::_nil ();
    }

  return tio->_this ();
}

TimeBase::UtcT TAO_UTO::utc_time ( void   )  [virtual]

For the readonly attribute <utc_time>.

Definition at line 80 of file TAO_UTO.cpp.

{
  return attr_utc_time_;
}


Member Data Documentation

TimeBase::UtcT TAO_UTO::attr_utc_time_ [private]

The readonly attribute structure having the time, inaccuracy and displacement. The get methods for other readonly attributes (time, inaccuracy, tdf) defined in the IDL use the members of this structure and hence need not have separate member variables for them.

Definition at line 101 of file TAO_UTO.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines