📄 vglobalconfigdata.hxx
字号:
#ifndef VGLOBAL_CONFIG_DATA_H#define VGLOBAL_CONFIG_DATA_H/* ==================================================================== * The Vovida Software License, Version 1.0 * * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The names "VOCAL", "Vovida Open Communication Application Library", * and "Vovida Open Communication Application Library (VOCAL)" must * not be used to endorse or promote products derived from this * software without prior written permission. For written * permission, please contact vocal@vovida.org. * * 4. Products derived from this software may not be called "VOCAL", nor * may "VOCAL" appear in their name, without prior written * permission of Vovida Networks, Inc. * * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH * DAMAGE. * * ==================================================================== * * This software consists of voluntary contributions made by Vovida * Networks, Inc. and many individuals on behalf of Vovida Networks, * Inc. For more information on Vovida Networks, Inc., please see * <http://www.vovida.org/>. * */static const char* const VGlobalConfigData_hxx_Version = "$Id$";#include <stdio.h>#include <string>#include "VException.hxx"#include "VXmlParser.hxx"/// Global configuration data containerclass VGlobalConfigData{ public: /// VGlobalConfigData (void) {} /// Constructor from XML content string VGlobalConfigData (string &xml) throw (VException&) { parse(xml); } /// parse the XML input void parse (string &xml) throw (VException&) { VXmlParser parser(xml); xmlNode *theNode = parser.findNode(NULL, "expiryTimer"); _expiryTimer = strtoul(parser.getAttribute(theNode, "value").c_str(), NULL, 10); theNode = parser.findNode(NULL, "multicastHost"); _multiCastHost = parser.getAttribute(theNode, "host"); _multiCastHostPort = atoi(parser.getAttribute(theNode, "port").c_str()); theNode = parser.findNode(NULL, "maxMissedHeartbeats"); _maxMissedHeartbeats = atoi(parser.getAttribute(theNode, "value").c_str()); theNode = parser.findNode(NULL, "heartbeatInterval"); _heartbeatInterval = atoi(parser.getAttribute(theNode, "value").c_str()); theNode = parser.findNode(NULL, "proxyAuthKey"); _proxyAuthKey = parser.getAttribute(theNode, "value"); theNode = parser.findNode(NULL, "redirectReasonInSIP"); string temp = parser.getAttribute(theNode, "value"); if (temp == "true" ) { _redirReason = true; } else { _redirReason = false; } } /// Assignment operator VGlobalConfigData operator= (const VGlobalConfigData& copy) { if (this != ©) { deepCopy(copy); } return *this; } /// Copy constructor VGlobalConfigData (const VGlobalConfigData& copy) { deepCopy(copy); } /// const string& getMultiCast() const { return _multiCastHost; }/// int getMultiCastPort() const { return _multiCastHostPort; } /// unsigned long getExpiryTimer() const { return _expiryTimer; } /// int getMaxMissedHB() const { return _maxMissedHeartbeats; } /// int getHBInterval() const { return _heartbeatInterval; } /// const string& getproxyAuthKey() const { return _proxyAuthKey; } /// bool getRedirReasonInSIP() const { return _redirReason; } /// friend ostream& operator<< (ostream &os, const VGlobalConfigData &elem); private: /// copy operation to copy all elements (used by copy constructor and assign) void deepCopy(const VGlobalConfigData ©) { _multiCastHost = copy._multiCastHost; _multiCastHostPort = copy._multiCastHostPort; _expiryTimer = copy._expiryTimer; _maxMissedHeartbeats = copy._maxMissedHeartbeats; _heartbeatInterval = copy._heartbeatInterval; _proxyAuthKey = copy._proxyAuthKey; _redirReason = copy._redirReason; }; string _multiCastHost; int _multiCastHostPort; unsigned long _expiryTimer; int _maxMissedHeartbeats; int _heartbeatInterval; string _proxyAuthKey; bool _redirReason;};///inline ostream& operator<<(ostream &os, const VGlobalConfigData &elem){ os << "Host: " << elem._multiCastHost << endl; os << "Port: " << elem._multiCastHostPort << endl; os << "Timer: " << elem._expiryTimer << endl; os << "Max HB: " << elem._maxMissedHeartbeats << endl; os << "HB Int: " << elem._heartbeatInterval << endl; os << "Proxy Auth Key: " << elem._proxyAuthKey << endl; os << "Redirect Reason in SIP: " << elem._redirReason << endl; return os;}#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -