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

bulkDataNTConfigurationParser.h

Go to the documentation of this file.
00001 #ifndef _BULKDATA_NT_CONFIGURATION_PARSER_H_
00002 #define _BULKDATA_NT_CONFIGURATION_PARSER_H_
00003 
00004 /*******************************************************************************
00005 * ALMA - Atacama Large Millimiter Array
00006 * (c) European Southern Observatory, 2011
00007 *
00008 * This library is free software; you can redistribute it and/or
00009 * modify it under the terms of the GNU Lesser General Public
00010 * License as published by the Free Software Foundation; either
00011 * version 2.1 of the License, or (at your option) any later version.
00012 *
00013 * This library is distributed in the hope that it will be useful,
00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00016 * Lesser General Public License for more details.
00017 *
00018 * You should have received a copy of the GNU Lesser General Public
00019 * License along with this library; if not, write to the Free Software
00020 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
00021 *
00022 * "@(#) $Id: bulkDataNTConfigurationParser.h,v 1.15 2013/02/06 13:59:09 bjeram Exp $"
00023 *
00024 * who       when      what
00025 * --------  --------  ----------------------------------------------
00026 * bjeram  2011-04-19  created
00027 */
00028 
00029 #ifndef __cplusplus
00030 #error This is a C++ include file and cannot be used from plain C
00031 #endif
00032 
00033 #include <map>
00034 #include <string>
00035 #include <set>
00036 
00037 #include <xercesc/dom/DOMNode.hpp>
00038 #include <xercesc/dom/DOMWriter.hpp>
00039 #include <xercesc/parsers/AbstractDOMParser.hpp>
00040 
00041 #include "bulkDataNTSenderStream.h"
00042 #include "bulkDataNTReceiverStream.h"
00043 
00044 namespace AcsBulkdata
00045 {
00046 
00047         class XMLChSP {
00048 
00049         public:
00050                 XMLChSP();
00051                 XMLChSP(char* xmlCh);
00052                 ~XMLChSP();
00053                 char * get();
00054                 XMLChSP& operator=(const char*);
00055                 void release();
00056 
00057         private:
00058                 char* xmlch_m;
00059 
00060         };
00061 
00062         class BulkDataConfigurationParser {
00063 
00064         private:
00065 
00066                 const char                 *m_baseLibrary; 
00067                 xercesc::DOMWriter         *m_writer;
00068                 xercesc::AbstractDOMParser *m_parser;
00069                 std::string                                         m_baseQoSlibrary; 
00070 
00071                 typedef struct _SenderCfg {
00072                         SenderStreamConfiguration *streamCfg;
00073                         std::map<std::string, SenderFlowConfiguration *> flowsCfgMap;
00074                 } SenderCfg;
00075 
00076                 typedef struct _ReceiverCfg {
00077                         ReceiverStreamConfiguration *streamCfg;
00078                         std::map<std::string, ReceiverFlowConfiguration *> flowsCfgMap;
00079                 } ReceiverCfg;
00080 
00081                 typedef std::map<std::string, ReceiverCfg> ReceiverCfgMap;
00082                 typedef std::map<std::string, SenderCfg>   SenderCfgMap;
00083 
00084                 ReceiverCfgMap receiverConfigMap_m;
00085                 SenderCfgMap   senderConfigMap_m;
00086 
00087                 static const char* const SENDER_STREAM_NODENAME;
00088                 static const char* const SENDER_STREAM_QOS_NODENAME;
00089                 static const char* const SENDER_FLOW_NODENAME;
00090                 static const char* const SENDER_FLOW_QOS_NODENAME;
00091                 static const char* const RECEIVER_STREAM_NODENAME;
00092                 static const char* const RECEIVER_STREAM_QOS_NODENAME;
00093                 static const char* const RECEIVER_FLOW_NODENAME;
00094                 static const char* const RECEIVER_FLOW_QOS_NODENAME;
00095 
00096                 static const char* const DYNAMIC_LIBRARY_NAME;
00097                 static const char* const DEFAULT_QOS_LIBRARY_NAME;
00098 
00099                 enum ParsingType {
00100                         SENDER,
00101                         RECEIVER
00102                 };
00103 
00104                 struct ParsingInfo {
00105                         ParsingType type;
00106                         const char* const reqStreamNodeName;
00107                         const char* const reqStreamQoSNodeName;
00108                         const char* const reqFlowNodeName;
00109                         const char* const reqFlowQoSNodeName;
00110                         const char* const defaultStreamProfileName;
00111                         const char* const defaultFlowProfileName;
00112                 };
00113 
00114                 const static struct ParsingInfo SENDER_PARSING_INFO;
00115                 const static struct ParsingInfo RECEIVER_PARSING_INFO;
00116 
00117 
00118                 void parseConfig(const char *config, const struct ParsingInfo &parsingInfo);
00119 
00120                 const XMLCh* getAttrValue(xercesc::DOMNode *node, const char * name);
00121 
00122                 unsigned short getUnsignedShortFromAttribute(xercesc::DOMNode *node, const char * attribute, unsigned short defaultVal);
00123 
00124                 double getDoubleFromAttribute(xercesc::DOMNode *node, const char * attribute, double defaultVal);
00125 
00126                 std::string getStringFromAttribute(xercesc::DOMNode *node, const char * attribute, std::string defaultVal);
00127 
00128                 bool getBooleanFromAttribute(xercesc::DOMNode *node, const char * attribute, bool defaultVal);
00129 
00130                 std::string getQosProfile(const char *profileName, const char *baseProfile, xercesc::DOMNode *node);
00131 
00132                 std::string getStrURIforStream(std::list<std::string> profiles);
00133 
00134                 void cleanReceiverConfigs();
00135 
00136                 void cleanSenderConfigs();
00137 
00138                 void cleanConfig(ReceiverCfg *recvConfig, SenderCfg *senderConfig, ParsingType type);
00139 
00140                 std::string getElementLocalName(xercesc::DOMNode *node);
00141 
00142         public:
00143 
00157                 BulkDataConfigurationParser(const char *baseLibraryName);
00158 
00162                 ~BulkDataConfigurationParser();
00163 
00169                 void parseSenderConfig(char const *configXML);
00175                 void parseReceiverConfig(char const *configXML);
00176 
00181                 std::set<char const *> getAllSenderStreamNames();
00182 
00187                 std::set<char const *> getAllReceiverStreamNames();
00188 
00197                 std::set<char const *> getAllSenderFlowNames(char const *streamName);
00198 
00204                 std::set<char const *> getAllReceiverFlowNames(char const *streamName);
00205 
00213                 SenderStreamConfiguration * getSenderStreamConfiguration(char const *streamName);
00214 
00223                 SenderFlowConfiguration * getSenderFlowConfiguration(char const *streamName, char const *flowName);
00224 
00232                 ReceiverStreamConfiguration * getReceiverStreamConfiguration(char const *streamName);
00233 
00242                 ReceiverFlowConfiguration * getReceiverFlowConfiguration(char const *streamName, char const *flowName);
00243         };
00244 
00245 };
00246 
00247 #endif

Generated on Mon May 4 2015 08:27:43 for ACS-2015.4 C++ API by  doxygen 1.7.0