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

cdbDAONode.h

Go to the documentation of this file.
00001 #ifndef cdbDAONode_H_
00002 #define cdbDAONode_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  *
00025  * "@(#) $Id: cdbDAONode.h,v 1.7 2010/04/20 14:33:39 bjeram Exp $"
00026  *
00027  * who       when        what
00028  * --------  ----------  ----------------------------------------------
00029  * msekoran  2005/09/11  created
00030  */
00031 
00032 #ifndef __cplusplus
00033 #error This is a C++ include file and cannot be used from plain C
00034 #endif
00035 
00036 #include <string>
00037 #include <map>
00038 
00039 #include "cdbDAOProxy.h"
00040 #include <cdbDALS.h>
00041 
00042 namespace cdb {
00043 
00044     // forward declaration
00045     class DAONode;
00046 
00050     class DALChangeListenerImplementation :
00051         public virtual PortableServer::RefCountServantBase,
00052         public virtual POA_CDB::DALChangeListener,
00053         public virtual POA_ACS::OffShoot
00054     {
00055       public:
00056 
00062         DALChangeListenerImplementation(CDB::DAL_ptr, PortableServer::POA_ptr poa);
00063 
00067         virtual ~DALChangeListenerImplementation();
00068         
00072         void registerNode(DAONode *node);
00073 
00077         void unregisterNode(DAONode *node);
00078 
00082         void destroy();
00083 
00084         //----------------------------------------------------
00085         // CORBA DALChangeListenerImplementation interface
00086         //----------------------------------------------------
00087 
00088         virtual void object_changed (const char * curl);
00089 
00090       protected:
00091 
00093         CDB::DAL_var m_dal;
00094         
00096         long m_changeListenerID;
00097 
00098         typedef std::vector<DAONode*> VectorDAONode;
00099         typedef std::map<std::string, VectorDAONode> MapVectorDAONode;
00100         
00102         MapVectorDAONode nodeMap;
00103 
00105         PortableServer::POA_var m_poa;
00106     };
00107 
00111     class DAONode :
00112         public virtual POA_CDB::DAO
00113     {
00114       public:
00115 
00122         DAONode(const char* nodeName, CDB::DAL_ptr dal, PortableServer::POA_ptr poa);
00123 
00127         virtual ~DAONode();
00128 
00132         void readConfiguration();
00133 
00138         DAONode* createDAONode(const char * nodeName);
00139         
00144         DAONode* createChild(const char* childName);
00145 
00146         //----------------------------------------------------
00147         // CORBA DAO interface
00148         //----------------------------------------------------
00149     /*
00150     * @throw cdbErrType::WrongCDBDataTypeEx
00151     * @throw cdbErrType::CDBFieldDoesNotExistEx
00152     */
00153         virtual CORBA::Long get_long (const char * propertyName);
00154 
00155     /*
00156     * @throw cdbErrType::WrongCDBDataTypeEx
00157     * @throw cdbErrType::CDBFieldDoesNotExistEx
00158     */
00159         virtual CORBA::Double get_double (const char * propertyName);
00160 
00161     /*
00162     * @throw cdbErrType::WrongCDBDataTypeEx
00163     * @throw cdbErrType::CDBFieldDoesNotExistEx
00164     */
00165         virtual char * get_string (const char * propertyName);
00166 
00167     /*
00168     * @throw cdbErrType::WrongCDBDataTypeEx
00169     * @throw cdbErrType::CDBFieldDoesNotExistEx
00170     */
00171         virtual char * get_field_data (const char * propertyName);
00172 
00173     /*
00174     * @throw cdbErrType::WrongCDBDataTypeEx
00175     * @throw cdbErrType::CDBFieldDoesNotExistEx
00176     */
00177         virtual ::CDB::stringSeq * get_string_seq (const char * propertyName);
00178 
00179     /*
00180     * @throw cdbErrType::WrongCDBDataTypeEx
00181     * @throw cdbErrType::CDBFieldDoesNotExistEx
00182     */
00183         virtual ::CDB::longSeq * get_long_seq (const char * propertyName);
00184     
00185     /*
00186     * @throw cdbErrType::WrongCDBDataTypeEx
00187     * @throw cdbErrType::CDBFieldDoesNotExistEx
00188     */
00189         virtual ::CDB::doubleSeq * get_double_seq (const char * propertyName);
00190 
00197         template<class T>
00198         T getValue(const char * propertyName);
00199 
00200         virtual void destroy ();
00201 
00202       protected:
00203 
00207         DAONode();
00208 
00214         void connect(bool silent = true);
00215 
00217         std::string m_name;
00218 
00220         CDB::DAL_var m_dal;
00221 
00223         PortableServer::POA_var m_poa;
00224 
00226         DAOProxy* m_daoImpl;
00227 
00229         bool m_remote;
00230         
00232         DALChangeListenerImplementation* m_dalChangeListener;
00233 
00234         // used to access m_name field and connect method
00235         friend class DALChangeListenerImplementation;
00236     };
00237 
00241     class DAOChildNode :
00242         public DAONode
00243     {
00244       public:
00245 
00251         DAOChildNode(DAONode * parent, const char* childName);
00252 
00256         virtual ~DAOChildNode();
00257         
00262         DAONode* createDAONode(const char * nodeName);
00263 
00268         DAONode* createChild(const char* childName);
00269 
00270         //----------------------------------------------------
00271         // CORBA DAO interface
00272         //----------------------------------------------------
00273 
00274     /*
00275     * @throw cdbErrType::WrongCDBDataTypeEx
00276     * @throw cdbErrType::CDBFieldDoesNotExistEx
00277     */
00278         virtual CORBA::Long get_long (const char * propertyName);
00279 
00280     /*
00281     * @throw cdbErrType::WrongCDBDataTypeEx
00282     * @throw cdbErrType::CDBFieldDoesNotExistEx
00283     */
00284         virtual CORBA::Double get_double (const char * propertyName);
00285 
00286     /*
00287     * @throw cdbErrType::WrongCDBDataTypeEx
00288     * @throw cdbErrType::CDBFieldDoesNotExistEx
00289     */
00290         virtual char * get_string (const char * propertyName);
00291 
00292     /*
00293     * @throw cdbErrType::WrongCDBDataTypeEx
00294     * @throw cdbErrType::CDBFieldDoesNotExistEx
00295     */
00296         virtual char * get_field_data (const char * propertyName);
00297 
00298     /*
00299     * @throw cdbErrType::WrongCDBDataTypeEx
00300     * @throw cdbErrType::CDBFieldDoesNotExistEx
00301     */
00302         virtual ::CDB::stringSeq * get_string_seq (const char * propertyName);
00303 
00304     /*
00305     * @throw cdbErrType::WrongCDBDataTypeEx
00306     * @throw cdbErrType::CDBFieldDoesNotExistEx
00307     */
00308         virtual ::CDB::longSeq * get_long_seq (const char * propertyName);
00309 
00310     /*
00311     * @throw cdbErrType::WrongCDBDataTypeEx
00312     * @throw cdbErrType::CDBFieldDoesNotExistEx
00313     */
00314         virtual ::CDB::doubleSeq * get_double_seq (const char * propertyName);
00315 
00316         /*
00317          * @throw cdbErrType::WrongCDBDataTypeEx
00318          * @throw cdbErrType::CDBFieldDoesNotExistEx
00319    */
00320         template<class T>
00321         T getValue(const char * propertyName)
00322         {
00323                 return m_parent->getValue<T>(propertyName);
00324         }
00325 
00326         virtual void destroy ();
00327 
00328       protected:
00329         
00331         DAONode* m_parent;
00332 
00334         std::string m_childName;
00335 
00337         std::string m_childNamePrefix;
00338     };
00339 
00340 } /* namespace cdb */
00341 
00342 #endif /* cdbDAONode_H_  */
00343 
00344 
00345 // -------------------------------------------------------
00346 /*___oOo___*/
00347 
00348 
00349 
00350 

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