From 92a6531e409f2691d82591e185a92299d415fc0f Mon Sep 17 00:00:00 2001 From: Joe George Date: Thu, 28 Jan 2021 16:26:44 -0500 Subject: IceGrid and IceStorm --- cpp/src/IceGrid/DescriptorParser.cpp | 100 +++++++++++++---------------------- 1 file changed, 36 insertions(+), 64 deletions(-) (limited to 'cpp/src/IceGrid/DescriptorParser.cpp') diff --git a/cpp/src/IceGrid/DescriptorParser.cpp b/cpp/src/IceGrid/DescriptorParser.cpp index b86f8cbb775..26cd9c24104 100644 --- a/cpp/src/IceGrid/DescriptorParser.cpp +++ b/cpp/src/IceGrid/DescriptorParser.cpp @@ -16,22 +16,22 @@ using namespace std; using namespace Ice; using namespace IceGrid; -namespace IceGrid +namespace { -class DescriptorHandler : public IceXML::Handler +class DescriptorHandler final : public IceXML::Handler { public: - DescriptorHandler(const string&, const Ice::CommunicatorPtr&); + DescriptorHandler(const string&, const shared_ptr&); - void setAdmin(const IceGrid::AdminPrx&); + void setAdmin(const shared_ptr&); void setVariables(const map&, const vector&); - virtual void startElement(const string&, const IceXML::Attributes&, int, int); - virtual void endElement(const string&, int, int); - virtual void characters(const string&, int, int); - virtual void error(const string&, int, int); + void startElement(const string&, const IceXML::Attributes&, int, int) override; + void endElement(const string&, int, int) override; + void characters(const string&, int, int) override; + void error(const string&, int, int) override; const ApplicationDescriptor& getApplicationDescriptor() const; @@ -43,8 +43,8 @@ private: void error(const string&) const; bool isTargetDeployable(const string&) const; - const Ice::CommunicatorPtr _communicator; - IceGrid::AdminPrx _admin; + const shared_ptr _communicator; + shared_ptr _admin; string _filename; map _overrides; vector _targets; @@ -55,38 +55,34 @@ private: int _line; int _column; - IceInternal::UniquePtr _currentApplication; - IceInternal::UniquePtr _currentNode; - IceInternal::UniquePtr _currentTemplate; - IceInternal::UniquePtr _currentServerInstance; - IceInternal::UniquePtr _currentServiceInstance; - IceInternal::UniquePtr _currentServer; - IceInternal::UniquePtr _currentService; + unique_ptr _currentApplication; + unique_ptr _currentNode; + unique_ptr _currentTemplate; + unique_ptr _currentServerInstance; + unique_ptr _currentServiceInstance; + unique_ptr _currentServer; + unique_ptr _currentService; CommunicatorDescriptorBuilder* _currentCommunicator; - IceInternal::UniquePtr _currentPropertySet; + unique_ptr _currentPropertySet; bool _isTopLevel; bool _inAdapter; bool _inReplicaGroup; - bool _inDbEnv; }; -} - -DescriptorHandler::DescriptorHandler(const string& filename, const Ice::CommunicatorPtr& communicator) : +DescriptorHandler::DescriptorHandler(const string& filename, const shared_ptr& communicator) : _communicator(communicator), _filename(filename), _isCurrentTargetDeployable(true), - _currentCommunicator(0), + _currentCommunicator(nullptr), _isTopLevel(true), _inAdapter(false), - _inReplicaGroup(false), - _inDbEnv(false) + _inReplicaGroup(false) { } void -DescriptorHandler::setAdmin(const AdminPrx& admin) +DescriptorHandler::setAdmin(const shared_ptr& admin) { _admin = admin; } @@ -405,15 +401,6 @@ DescriptorHandler::startElement(const string& name, const IceXML::Attributes& at } _currentCommunicator->addAllocatable(attributes); } - else if(name == "dbenv") - { - if(!_currentCommunicator) - { - error("the element can only be a child of a or element"); - } - _currentCommunicator->addDbEnv(attributes); - _inDbEnv = true; - } else if(name == "log") { if(!_currentCommunicator) @@ -422,14 +409,6 @@ DescriptorHandler::startElement(const string& name, const IceXML::Attributes& at } _currentCommunicator->addLog(attributes); } - else if(name == "dbproperty") - { - if(!_inDbEnv) - { - error("the element can only be a child of a element"); - } - _currentCommunicator->addDbEnvProperty(attributes); - } else if(name == "description" || name == "option" || name == "env") { // @@ -488,7 +467,7 @@ DescriptorHandler::endElement(const string& name, int line, int column) else if(name == "node") { _currentApplication->addNode(_currentNode->getName(), _currentNode->getDescriptor()); - _currentNode.reset(0); + _currentNode.reset(nullptr); } else if(name == "server" || name == "icebox") { @@ -503,14 +482,14 @@ DescriptorHandler::endElement(const string& name, int line, int column) _currentNode->addServer(_currentServer->getDescriptor()); } _currentServer->finish(); - _currentServer.reset(0); - _currentCommunicator = 0; + _currentServer.reset(nullptr); + _currentCommunicator = nullptr; } else if(name == "server-template") { assert(_currentApplication.get()); _currentApplication->addServerTemplate(_currentTemplate->getId(), _currentTemplate->getDescriptor()); - _currentTemplate.reset(0); + _currentTemplate.reset(nullptr); } else if(name == "service") { @@ -524,26 +503,26 @@ DescriptorHandler::endElement(const string& name, int line, int column) _currentTemplate->setDescriptor(_currentService->getDescriptor()); } _currentService->finish(); - _currentService.reset(0); + _currentService.reset(nullptr); _currentCommunicator = _currentServer.get(); } else if(name == "service-template") { assert(_currentTemplate.get()); _currentApplication->addServiceTemplate(_currentTemplate->getId(), _currentTemplate->getDescriptor()); - _currentTemplate.reset(0); + _currentTemplate.reset(nullptr); } else if(name == "server-instance") { assert(_currentNode.get() && _currentServerInstance.get()); _currentNode->addServerInstance(_currentServerInstance->getDescriptor()); - _currentServerInstance.reset(0); + _currentServerInstance.reset(nullptr); } else if(name == "service-instance") { assert(_currentServer.get() && _currentServiceInstance.get()); _currentServer->addServiceInstance(_currentServiceInstance->getDescriptor()); - _currentServiceInstance.reset(0); + _currentServiceInstance.reset(nullptr); } else if(name == "properties") { @@ -577,7 +556,7 @@ DescriptorHandler::endElement(const string& name, int line, int column) { assert(false); } - _currentPropertySet.reset(0); + _currentPropertySet.reset(nullptr); } } else if(name == "description") @@ -590,11 +569,6 @@ DescriptorHandler::endElement(const string& name, int line, int column) { _currentApplication->setReplicaGroupDescription(elementValue()); } - else if(_inDbEnv) - { - assert(_currentCommunicator); - _currentCommunicator->setDbEnvDescription(elementValue()); - } else if(_currentCommunicator) { _currentCommunicator->setDescription(elementValue()); @@ -637,10 +611,6 @@ DescriptorHandler::endElement(const string& name, int line, int column) _currentApplication->finishReplicaGroup(); _inReplicaGroup = false; } - else if(name == "dbenv") - { - _inDbEnv = false; - } } catch(const exception& ex) { @@ -811,12 +781,14 @@ DescriptorHandler::isTargetDeployable(const string& target) const return false; } +} + ApplicationDescriptor DescriptorParser::parseDescriptor(const string& descriptor, const Ice::StringSeq& targets, const map& variables, - const Ice::CommunicatorPtr& communicator, - const IceGrid::AdminPrx& admin) + const shared_ptr& communicator, + const shared_ptr& admin) { string filename = simplify(descriptor); DescriptorHandler handler(filename, communicator); @@ -827,7 +799,7 @@ DescriptorParser::parseDescriptor(const string& descriptor, } ApplicationDescriptor -DescriptorParser::parseDescriptor(const string& descriptor, const Ice::CommunicatorPtr& communicator) +DescriptorParser::parseDescriptor(const string& descriptor, const shared_ptr& communicator) { string filename = simplify(descriptor); DescriptorHandler handler(filename, communicator); -- cgit v1.2.3