📄 aaad_config.h
字号:
/* BEGIN_COPYRIGHT *//* *//* Open Diameter: Open-source software for the Diameter and *//* Diameter related protocols *//* *//* Copyright (C) 2002-2004 Open Diameter Project *//* *//* This library is free software; you can redistribute it and/or modify *//* it under the terms of the GNU Lesser General Public License as *//* published by the Free Software Foundation; either version 2.1 of the *//* License, or (at your option) any later version. *//* *//* This library is distributed in the hope that it will be useful, *//* but WITHOUT ANY WARRANTY; without even the implied warranty of *//* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *//* Lesser General Public License for more details. *//* *//* You should have received a copy of the GNU Lesser General Public *//* License along with this library; if not, write to the Free Software *//* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *//* USA. *//* *//* In addition, when you copy and redistribute some or the entire part of *//* the source code of this software with or without modification, you *//* MUST include this copyright notice in each copy. *//* *//* If you make any changes that are appeared to be useful, please send *//* sources that include the changed part to *//* diameter-developers@lists.sourceforge.net so that we can reflect your *//* changes to one unified version of this software. *//* *//* END_COPYRIGHT */#ifndef __AAAD_CONFIG_H__#define __AAAD_CONFIG_H__#include "od_utl_xml_parser.h"#include "aaad_defs.h"template <class ELEMENT_PARSER>class AAAD_ParserMultiElement{ public: virtual ~AAAD_ParserMultiElement() { } AAAD_ParserMultiElement(const char *name) : m_ElementParser(name) { } ELEMENT_PARSER &operator()(void) { return m_ElementParser; } virtual void populate(DOMNode *n) { DOMNode *found, *child = n->getFirstChild(); while (child) { if (m_ElementParser.populate(child, &found) != 0) { break; } child = found->getNextSibling(); } } private: ELEMENT_PARSER m_ElementParser;};template <class ELEMENT>class AAAD_ParserElement : public OD_Utl_XMLElementParser{ public: AAAD_ParserElement(const char *name) : OD_Utl_XMLElementParser(name) { } virtual int svc(DOMNode *n) { std::string apName; std::string enableVar; bool bEnabled = false; OD_Utl_XMLDataString name("name", apName); name.populate(n->getFirstChild()); OD_Utl_XMLDataString enabled("enabled", enableVar); if (enabled.populate(n->getFirstChild()) == 0) { bEnabled = (enableVar == "true") ? true : false; } ELEMENT e(apName.data(), bEnabled); e.populate(n->getFirstChild()); return (0); }};class AAAD_ParserElementWithNameCheck : public OD_Utl_XMLElementParserWithData<bool>{ public: AAAD_ParserElementWithNameCheck(const char *name, bool bEnabled, const char *check) : OD_Utl_XMLElementParserWithData<bool>(name, bEnabled), m_NameCheck(check) { } virtual int operator()(DOMNode *n) = 0; virtual int svc(DOMNode *n) { if (m_Name == m_NameCheck) { return (*this)(n); } return (0); } protected: std::string m_NameCheck;};class AAAD_ParserApplicationEntry : public AAAD_ParserElementWithNameCheck{ public: AAAD_ParserApplicationEntry(const char *name, bool bEnabled) : AAAD_ParserElementWithNameCheck (name, bEnabled, "diameter_eap") { } virtual int operator()(DOMNode *n) { std::auto_ptr<AAAD_MapElement> app(new AAAD_AppDiamEapData); AAAD_AppDiamEapData &appRef = (AAAD_AppDiamEapData&)(*app); OD_Utl_XMLDataString ident("local_identity", appRef.Application().LocalIdentity()); ident.populate(n->getFirstChild()); OD_Utl_XMLDataString user("user_db", appRef.Application().UserDbFile()); user.populate(n->getFirstChild()); appRef.Name() = m_Name; appRef.Enabled() = m_Payload; AAAD_APP_TBL().Register(app); return (0); }};class AAAD_ParserApplications : public OD_Utl_XMLElementParser{ public: AAAD_ParserApplications(const char *name) : OD_Utl_XMLElementParser(name) { } virtual int svc(DOMNode *n) { // Add other diameter application parsers here AAAD_ParserMultiElement <AAAD_ParserElement <AAAD_ParserApplicationEntry> > appEntries("application_entry"); appEntries.populate(n); return 0; }};class AAAD_ParserAaad : public OD_Utl_XMLElementParser{ public: AAAD_ParserAaad(const char *name) : OD_Utl_XMLElementParser(name) { } virtual int svc(DOMNode *n) { OD_Utl_XMLDataUInt32 tcount("thread_count", (ACE_UINT32&)AAAD_CFG_DATA()->ThreadCount()); tcount.populate(n->getFirstChild()); OD_Utl_XMLDataString cfgFile("diameter_cfg_file", AAAD_CFG_DATA()->DiameterCfgFile()); cfgFile.populate(n->getFirstChild()); AAAD_ParserApplications apps("applications"); apps.populate(n->getFirstChild()); return (0); }};class AAAD_CfgLoader{ public: AAAD_CfgLoader(const char *name) { Open(name); } protected: int Open(const char *name) { OD_Utl_XMLTreeParser parser; AAAD_ParserAaad root("aaad"); return parser.open(name, root); }};#endif // __AAAD_CONFIG_H__
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -