Revert "Minor modernization of DynamicAny code"
[ACE_TAO.git] / TAO / tao / PortableServer / LifespanStrategyTransient.cpp
blobeb6ed65faeb6defada4259951cbff0e0372ae03c
1 // -*- C++ -*-
2 #include "tao/PortableServer/LifespanStrategyTransient.h"
3 #include "ace/OS_NS_sys_time.h"
4 #include "ace/OS_NS_string.h"
5 #include "tao/PortableServer/POAManager.h"
6 #include "tao/PortableServer/Root_POA.h"
7 #include "tao/ORB_Constants.h"
8 #include "tao/PortableServer/Creation_Time.h"
10 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
12 namespace TAO
14 namespace Portable_Server
16 LifespanStrategyTransient::LifespanStrategyTransient () :
17 creation_time_ (ACE_OS::gettimeofday ())
21 void
22 LifespanStrategyTransient::notify_startup ()
26 void
27 LifespanStrategyTransient::notify_shutdown ()
31 CORBA::Boolean
32 LifespanStrategyTransient::is_persistent () const
34 return false;
37 bool
38 LifespanStrategyTransient::validate (CORBA::Boolean is_persistent,
39 const TAO::Portable_Server::
40 Temporary_Creation_Time
41 &creation_time) const
43 return (!is_persistent && this->creation_time_ == creation_time);
46 CORBA::ULong
47 LifespanStrategyTransient::key_length () const
49 CORBA::ULong keylength = sizeof (char);
51 #if (POA_NO_TIMESTAMP == 0)
52 // Calculate the space required for the timestamp.
53 keylength += TAO::Portable_Server::Creation_Time::creation_time_length
54 ();
55 #endif /* POA_NO_TIMESTAMP */
57 return keylength;
60 void
61 LifespanStrategyTransient::create_key (CORBA::Octet *buffer,
62 CORBA::ULong &starting_at)
64 // Copy the persistence byte.
65 buffer[starting_at] = (CORBA::Octet)this->key_type ();
66 starting_at += this->key_type_length ();
68 #if (POA_NO_TIMESTAMP == 0)
69 // Then copy the timestamp for transient POAs.
70 ACE_OS::memcpy (&buffer[starting_at],
71 this->creation_time_.creation_time (),
72 TAO::Portable_Server::Creation_Time::creation_time_length
73 ());
74 starting_at += TAO::Portable_Server::Creation_Time::creation_time_length
75 ();
76 #endif /* POA_NO_TIMESTAMP */
79 char
80 LifespanStrategyTransient::key_type () const
82 return 'T';
85 void
86 LifespanStrategyTransient::check_state ()
88 if (this->poa_->tao_poa_manager ().get_state_i () ==
89 PortableServer::POAManager::INACTIVE)
91 throw ::CORBA::OBJECT_NOT_EXIST (CORBA::OMGVMCID | 4, CORBA::COMPLETED_NO);
93 else
95 this->poa_->tao_poa_manager ().check_state ();
99 bool
100 LifespanStrategyTransient::use_imr () const
102 return false;
105 CORBA::Object_ptr
106 LifespanStrategyTransient::imr_key_to_object (const TAO::ObjectKey &,
107 const char *) const
109 return CORBA::Object::_nil();
111 } /* namespace Portable_Server */
112 } /* namespace TAO */
114 TAO_END_VERSIONED_NAMESPACE_DECL