• Classes
  • Modules
  • Namespaces
  • Files
  • Related Pages
  • File List
  • File Members

acsImpBaseHandlerImpl.h

Go to the documentation of this file.
00001 #ifndef _ACS_IMP_BASE_HANDLER_IMPL_H_
00002 #define _ACS_IMP_BASE_HANDLER_IMPL_H_
00003 
00004 /*******************************************************************************
00005 *    ALMA - Atacama Large Millimiter Array
00006 *    (c) European Southern Observatory, 2002
00007 *    Copyright by ESO (in the framework of the ALMA collaboration)
00008 *    and Cosylab 2002, All rights reserved
00009 *
00010 *    This library is free software; you can redistribute it and/or
00011 *    modify it under the terms of the GNU Lesser General Public
00012 *    License as published by the Free Software Foundation; either
00013 *    version 2.1 of the License, or (at your option) any later version.
00014 *
00015 *    This library is distributed in the hope that it will be useful,
00016 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
00017 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018 *    Lesser General Public License for more details.
00019 *
00020 *    You should have received a copy of the GNU Lesser General Public
00021 *    License along with this library; if not, write to the Free Software
00022 *    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
00023 *
00024 * "@(#) $Id: acsImpBaseHandlerImpl.h,v 1.5 2009/07/27 11:27:59 msekoran Exp $"
00025 *
00026 * who       when      what
00027 * --------  --------  ----------------------------------------------
00028 * azagar   2008-09-30 created
00029 */
00030 
00031 #ifndef __cplusplus
00032 #error This is a C++ include file and cannot be used from plain C
00033 #endif
00034 
00035 #include "acsDaemonImpl.h"
00036 #include "acsRequest.h"
00037 #include "acsServiceController.h"
00038 
00039 
00040 
00041 template <class T> class ACSImpBaseHandlerImpl : public virtual POA_acsdaemon::ImpBase, public virtual DetailedServiceStateProvider {
00042 
00043   public:
00044     
00048     ACSImpBaseHandlerImpl(ACSServiceType iservice) : service(iservice) {
00049         context = new ACSDaemonContext(acsServices[service].impname, this);
00050     }
00051   
00055     virtual ~ACSImpBaseHandlerImpl() {
00056         ACS_SHORT_LOG((LM_DEBUG, "DESTROYING ACSImpHandlerImpl!"));
00057         delete context;
00058     }
00059 
00063     virtual acsdaemon::ServiceState getDetailedServiceState(ACSServiceRequestDescription *desc, CORBA::Object_ptr obj) {
00064         return acsdaemon::RUNNING;
00065     }
00066 
00070     void setService(ACSDaemonServiceImpl<T> *serviceimpl)
00071     {
00072         serviceimpl = serviceimpl;
00073     }
00074 
00078     void initialize(CORBA::ORB_ptr orb) {
00079         context->initialize(orb);
00080     }
00081 
00085     void dispose(CORBA::ORB_ptr orb) {
00086         context->dispose(orb);
00087     }
00088 
00092     std::string getName() {
00093         return acsServices[service].impname;
00094     }
00095 
00099     std::string getType() {
00100         return acsServices[service].imptype;
00101     }
00102     
00106     std::string getPort() {
00107         return acsServices[service].impport;
00108     }
00109     
00110     /*************************** CORBA interface *****************************/
00111 
00112     void shutdown() {
00113         if (serviceimpl->isProtected())
00114             {
00115             throw ::maciErrType::NoPermissionEx();
00116             }
00117         ACS_SHORT_LOG ((LM_INFO, "Shutting down the ACS Imp on remote request..."));
00118         serviceimpl->shutdown(false);
00119     }
00120 
00121     bool ping() {
00122         return true;
00123     }
00124 
00125     void set_manager_reference(
00126         const short instance_number,
00127         const char * ref
00128         )
00129     {
00130         if (context)
00131             context->setManagerReference(instance_number, ref);
00132     }
00133 
00134   protected:
00135     ACSServiceType service;
00136     ACSDaemonServiceImpl<T> *serviceimpl; // ACS daemon service
00137     ACSDaemonContext *context;
00138 };
00139 
00140 
00141 
00142 #endif

Generated on Thu Jan 12 2012 23:13:50 for ACS-10.0 C++ API by  doxygen 1.7.0