IdUniquenessStrategyFactoryImpl.cpp

Go to the documentation of this file.
00001 // $Id: IdUniquenessStrategyFactoryImpl.cpp 76551 2007-01-24 13:42:44Z johnnyw $
00002 
00003 #include "tao/PortableServer/IdUniquenessStrategyFactoryImpl.h"
00004 #include "tao/PortableServer/IdUniquenessStrategy.h"
00005 #include "ace/Dynamic_Service.h"
00006 
00007 ACE_RCSID (PortableServer,
00008            IdUniquenessStrategyFactoryImpl,
00009            "$Id: IdUniquenessStrategyFactoryImpl.cpp 76551 2007-01-24 13:42:44Z johnnyw $")
00010 
00011 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00012 
00013 namespace TAO
00014 {
00015   namespace Portable_Server
00016   {
00017     IdUniquenessStrategy*
00018     IdUniquenessStrategyFactoryImpl::create (
00019       ::PortableServer::IdUniquenessPolicyValue value)
00020     {
00021       IdUniquenessStrategy* strategy = 0;
00022       switch (value)
00023       {
00024         case ::PortableServer::MULTIPLE_ID :
00025         {
00026           strategy =
00027             ACE_Dynamic_Service<IdUniquenessStrategy>::instance ("IdUniquenessStrategyMultiple");
00028 
00029           if (strategy == 0)
00030             ACE_ERROR ((LM_ERROR,
00031                         ACE_TEXT ("(%P|%t) %p\n"),
00032                         ACE_TEXT ("ERROR, Unable to get ")
00033                         ACE_TEXT ("IdUniquenessStrategyMultiple")));
00034 
00035           break;
00036         }
00037         case ::PortableServer::UNIQUE_ID :
00038         {
00039           IdUniquenessStrategyFactory *strategy_factory =
00040             ACE_Dynamic_Service<IdUniquenessStrategyFactory>::instance ("IdUniquenessStrategyUniqueFactory");
00041 
00042           if (strategy_factory != 0)
00043             strategy = strategy_factory->create (value);
00044           else
00045             ACE_ERROR ((LM_ERROR,
00046                         ACE_TEXT ("(%P|%t) %p\n"),
00047                         ACE_TEXT ("ERROR, Unable to get ")
00048                         ACE_TEXT ("IdUniquenessStrategyUniqueFactory")));
00049 
00050           break;
00051         }
00052       }
00053 
00054       return strategy;
00055     }
00056 
00057     void
00058     IdUniquenessStrategyFactoryImpl::destroy (
00059       IdUniquenessStrategy *strategy
00060       )
00061     {
00062       switch (strategy->type ())
00063       {
00064         case ::PortableServer::MULTIPLE_ID :
00065         {
00066           // Noop
00067           break;
00068         }
00069         case ::PortableServer::UNIQUE_ID :
00070         {
00071           IdUniquenessStrategyFactory *strategy_factory =
00072             ACE_Dynamic_Service<IdUniquenessStrategyFactory>::instance ("IdUniquenessStrategyUniqueFactory");
00073 
00074           if (strategy_factory != 0)
00075             {
00076               strategy_factory->destroy (strategy);
00077             }
00078           break;
00079         }
00080       }
00081     }
00082 
00083   }
00084 }
00085 
00086 TAO_END_VERSIONED_NAMESPACE_DECL
00087 
00088 ACE_STATIC_SVC_DEFINE (
00089   IdUniquenessStrategyFactoryImpl,
00090   ACE_TEXT ("IdUniquenessStrategyFactory"),
00091   ACE_SVC_OBJ_T,
00092   &ACE_SVC_NAME (IdUniquenessStrategyFactoryImpl),
00093   ACE_Service_Type::DELETE_THIS | ACE_Service_Type::DELETE_OBJ,
00094   0)
00095 
00096 ACE_FACTORY_NAMESPACE_DEFINE (
00097   ACE_Local_Service,
00098   IdUniquenessStrategyFactoryImpl,
00099   TAO::Portable_Server::IdUniquenessStrategyFactoryImpl)

Generated on Tue Feb 2 17:40:54 2010 for TAO_PortableServer by  doxygen 1.4.7