00001 #ifndef basenc_helper_H 00002 #define basenc_helper_H 00003 /******************************************************************************* 00004 * ALMA - Atacama Large Millimiter Array 00005 * (c) National Research Council of Canada, 2005 00006 * 00007 * This library is free software; you can redistribute it and/or 00008 * modify it under the terms of the GNU Lesser General Public 00009 * License as published by the Free Software Foundation; either 00010 * version 2.1 of the License, or (at your option) any later version. 00011 * 00012 * This library is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 * Lesser General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU Lesser General Public 00018 * License along with this library; if not, write to the Free Software 00019 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00020 * 00021 * "@(#) $Id: basencHelper.h,v 1.6 2008/02/12 01:06:22 msekoran Exp $" 00022 * 00023 * who when what 00024 * -------- -------- ---------------------------------------------- 00025 * dfugate 2005-11-15 created 00026 */ 00027 00028 #ifndef __cplusplus 00029 #error This is a C++ include file and cannot be used from plain C 00030 #endif 00031 00032 #include <orbsvcs/CosNotifyChannelAdminS.h> 00033 #include <orbsvcs/CosNamingC.h> 00034 #include <acsncC.h> 00035 #include <cdbDALC.h> 00036 00041 class BaseHelper 00042 { 00043 public: 00044 00051 static char* getNotificationFactoryNameForChannel(CDB::DAL_ptr dal, const char* channelName, const char* domainName = 0); 00052 00053 protected: 00054 00060 BaseHelper(const char* channelName, const char* notifyServiceDomainName = 0); 00061 00067 virtual void 00068 init(CosNaming::NamingContext_ptr nc_p); 00069 00073 virtual ~BaseHelper(); 00074 00079 virtual void 00080 disconnect(); 00081 00090 virtual const char* 00091 getChannelKind() = 0; 00092 00100 virtual const char* 00101 getChannelDomain() 00102 {return acscommon::ALMADOMAIN;} 00103 00109 virtual const char* 00110 getNotificationFactoryName() 00111 { 00112 if (!notificationServiceName_mp) 00113 { 00114 // @todo temporary implementation, containerServices to be used 00115 CDB::DAL_var cdb; 00116 00117 //Common name sequence. This little object defines the name of 00118 //channel as registered with the CORBA Naming Service. 00119 CosNaming::Name name(1); 00120 name.length(1); 00121 00122 //name of the channel 00123 name[0].id = CORBA::string_dup("CDB"); 00124 //channel kind 00125 name[0].kind = CORBA::string_dup(""); 00126 00127 try 00128 { 00129 //use the naming service to get our object 00130 CORBA::Object_var dal_obj = namingContext_m->resolve(name); 00131 00132 //narrow it 00133 cdb = CDB::DAL::_narrow(dal_obj.in()); 00134 } 00135 catch(CosNaming::NamingContext::NotFound ex) 00136 { 00137 // noop 00138 } 00139 00140 notificationServiceName_mp = getNotificationFactoryNameForChannel(cdb.in(), channelName_mp, notifyServiceDomainName_mp); 00141 if (!notificationServiceName_mp) 00142 notificationServiceName_mp = CORBA::string_dup(acscommon::NOTIFICATION_FACTORY_NAME); 00143 } 00144 00145 return notificationServiceName_mp; 00146 } 00147 00154 virtual const CosNotification::QoSProperties 00155 getQoSProps(); 00156 00163 virtual const CosNotification::AdminProperties 00164 getAdminProps(); 00165 00174 virtual void 00175 createNotificationChannel(); 00176 00186 virtual void 00187 getNotifyService(); 00188 00197 virtual void 00198 attachChannelToNS(); 00199 00207 virtual void 00208 destroyNotificationChannel(); 00209 00210 //--members------------------------------------------------------------------------- 00214 CosNaming::NamingContext_var namingContext_m; 00215 00219 CosNotifyChannelAdmin::EventChannelFactory_var notifyFactory_m; 00220 00225 CosNotifyChannelAdmin::ChannelID channelID_m; 00226 00233 CosNotifyChannelAdmin::InterFilterGroupOperator ifgop_m; 00234 00240 CosNotifyChannelAdmin::EventChannel_var notifyChannel_m; 00241 00245 char* channelName_mp; 00246 00250 char *notifyServiceDomainName_mp; 00251 00255 char *notificationServiceName_mp; 00256 00260 bool initCalled_m; 00261 }; 00262 00263 #endif