diff options
Diffstat (limited to 'cpp/src/IceGrid/DescriptorHelper.cpp')
-rw-r--r-- | cpp/src/IceGrid/DescriptorHelper.cpp | 478 |
1 files changed, 183 insertions, 295 deletions
diff --git a/cpp/src/IceGrid/DescriptorHelper.cpp b/cpp/src/IceGrid/DescriptorHelper.cpp index 58ec1da1ec9..39cbcdebdef 100644 --- a/cpp/src/IceGrid/DescriptorHelper.cpp +++ b/cpp/src/IceGrid/DescriptorHelper.cpp @@ -13,42 +13,23 @@ using namespace IceUtil; using namespace IceUtilInternal; using namespace IceGrid; -#ifdef __SUNPRO_CC -// -// Disable warning about unassigned function objects -// -# pragma error_messages(off,unassigned) -#endif - -namespace IceGrid +namespace { -struct GetReplicaGroupId : unary_function<const ReplicaGroupDescriptor&, const string&> +const string& getReplicaGroupId(const ReplicaGroupDescriptor& desc) { - const string& - operator()(const ReplicaGroupDescriptor& desc) - { - return desc.id; - } -}; + return desc.id; +} -struct GetAdapterId : unary_function<const AdapterDescriptor&, const string&> +const string& getAdapterId(const AdapterDescriptor& desc) { - const string& - operator()(const AdapterDescriptor& desc) - { - return desc.id; - } -}; + return desc.id; +} -struct GetObjectId : unary_function<const ObjectDescriptor&, const Ice::Identity&> +const Ice::Identity& getObjectId(const ObjectDescriptor& desc) { - const Ice::Identity& - operator()(const ObjectDescriptor& desc) - { - return desc.id; - } -}; + return desc.id; +} template <typename GetKeyFunc, typename Seq, typename EqFunc> bool isSeqEqual(const Seq& lseq, const Seq& rseq, GetKeyFunc func, EqFunc eq = equal_to<typename Seq::value_type>()) @@ -76,162 +57,146 @@ isSeqEqual(const Seq& lseq, const Seq& rseq, GetKeyFunc func, EqFunc eq = equal_ return true; } -struct TemplateDescriptorEqual : std::binary_function<TemplateDescriptor&, TemplateDescriptor&, bool> +bool templateDescriptorEqual(const TemplateDescriptor& lhs, const TemplateDescriptor& rhs) { - bool - operator()(const TemplateDescriptor& lhs, const TemplateDescriptor& rhs) + if(lhs.parameters != rhs.parameters) { - if(lhs.parameters != rhs.parameters) - { - return false; - } + return false; + } - if(lhs.parameterDefaults != rhs.parameterDefaults) - { - return false; - } + if(lhs.parameterDefaults != rhs.parameterDefaults) + { + return false; + } + { + auto slhs = dynamic_pointer_cast<IceBoxDescriptor>(lhs.descriptor); + auto srhs = dynamic_pointer_cast<IceBoxDescriptor>(rhs.descriptor); + if(slhs && srhs) { - IceBoxDescriptorPtr slhs = IceBoxDescriptorPtr::dynamicCast(lhs.descriptor); - IceBoxDescriptorPtr srhs = IceBoxDescriptorPtr::dynamicCast(rhs.descriptor); - if(slhs && srhs) - { - return IceBoxHelper(slhs) == IceBoxHelper(srhs); - } + return IceBoxHelper(slhs) == IceBoxHelper(srhs); } + } + { + auto slhs = dynamic_pointer_cast<ServerDescriptor>(lhs.descriptor); + auto srhs = dynamic_pointer_cast<ServerDescriptor>(rhs.descriptor); + if(slhs && srhs) { - ServerDescriptorPtr slhs = ServerDescriptorPtr::dynamicCast(lhs.descriptor); - ServerDescriptorPtr srhs = ServerDescriptorPtr::dynamicCast(rhs.descriptor); - if(slhs && srhs) - { - return ServerHelper(slhs) == ServerHelper(srhs); - } + return ServerHelper(slhs) == ServerHelper(srhs); } + } + { + auto slhs = dynamic_pointer_cast<ServiceDescriptor>(lhs.descriptor); + auto srhs = dynamic_pointer_cast<ServiceDescriptor>(rhs.descriptor); + if(slhs && srhs) { - ServiceDescriptorPtr slhs = ServiceDescriptorPtr::dynamicCast(lhs.descriptor); - ServiceDescriptorPtr srhs = ServiceDescriptorPtr::dynamicCast(rhs.descriptor); - if(slhs && srhs) - { - return ServiceHelper(slhs) == ServiceHelper(srhs); - } + return ServiceHelper(slhs) == ServiceHelper(srhs); } - - return false; } -}; -struct ObjectDescriptorEq : std::binary_function<const ObjectDescriptor&, const ObjectDescriptor&, bool> + return false; +} + +bool objectDescriptorEqual(const ObjectDescriptor& lhs, const ObjectDescriptor& rhs) { - bool - operator()(const ObjectDescriptor& lhs, const ObjectDescriptor& rhs) + if(lhs.id != rhs.id) { - if(lhs.id != rhs.id) - { - return false; - } - if(lhs.type != rhs.type) - { - return false; - } - if(lhs.proxyOptions != rhs.proxyOptions) - { - return false; - } - return true; + return false; + } + if(lhs.type != rhs.type) + { + return false; + } + if(lhs.proxyOptions != rhs.proxyOptions) + { + return false; } -}; + return true; +} -struct AdapterEq : std::binary_function<const AdapterDescriptor&, const AdapterDescriptor&, bool> +bool adapterEqual(const AdapterDescriptor& lhs, const AdapterDescriptor& rhs) { - bool - operator()(const AdapterDescriptor& lhs, const AdapterDescriptor& rhs) + if(lhs.id != rhs.id) { - if(lhs.id != rhs.id) - { - return false; - } - if(lhs.name != rhs.name) - { - return false; - } - if(lhs.description != rhs.description) - { - return false; - } - if(lhs.replicaGroupId != rhs.replicaGroupId) - { - return false; - } - if(lhs.priority != rhs.priority) - { - return false; - } - if(lhs.registerProcess != rhs.registerProcess) - { - return false; - } - if(lhs.serverLifetime != rhs.serverLifetime) - { - return false; - } - if(!isSeqEqual(lhs.objects, rhs.objects, GetObjectId(), ObjectDescriptorEq())) - { - return false; - } - if(!isSeqEqual(lhs.allocatables, rhs.allocatables, GetObjectId(), ObjectDescriptorEq())) - { - return false; - } - return true; + return false; + } + if(lhs.name != rhs.name) + { + return false; + } + if(lhs.description != rhs.description) + { + return false; + } + if(lhs.replicaGroupId != rhs.replicaGroupId) + { + return false; } -}; + if(lhs.priority != rhs.priority) + { + return false; + } + if(lhs.registerProcess != rhs.registerProcess) + { + return false; + } + if(lhs.serverLifetime != rhs.serverLifetime) + { + return false; + } + if(!isSeqEqual(lhs.objects, rhs.objects, getObjectId, objectDescriptorEqual)) + { + return false; + } + if(!isSeqEqual(lhs.allocatables, rhs.allocatables, getObjectId, objectDescriptorEqual)) + { + return false; + } + return true; +} -struct ReplicaGroupEq : std::binary_function<const ReplicaGroupDescriptor&, const ReplicaGroupDescriptor&, bool> +bool replicaGroupEqual(const ReplicaGroupDescriptor& lhs, const ReplicaGroupDescriptor& rhs) { - bool - operator()(const ReplicaGroupDescriptor& lhs, const ReplicaGroupDescriptor& rhs) + if(lhs.id != rhs.id) { - if(lhs.id != rhs.id) - { - return false; - } - if(lhs.proxyOptions != rhs.proxyOptions) - { - return false; - } - if(lhs.filter != rhs.filter) + return false; + } + if(lhs.proxyOptions != rhs.proxyOptions) + { + return false; + } + if(lhs.filter != rhs.filter) + { + return false; + } + if(!isSeqEqual(lhs.objects, rhs.objects, getObjectId, objectDescriptorEqual)) + { + return false; + } + if(lhs.loadBalancing && rhs.loadBalancing) + { + if(lhs.loadBalancing->ice_id() != rhs.loadBalancing->ice_id()) { return false; } - if(!isSeqEqual(lhs.objects, rhs.objects, GetObjectId(), ObjectDescriptorEq())) + if(lhs.loadBalancing->nReplicas != rhs.loadBalancing->nReplicas) { return false; } - if(lhs.loadBalancing && rhs.loadBalancing) - { - if(lhs.loadBalancing->ice_id() != rhs.loadBalancing->ice_id()) - { - return false; - } - if(lhs.loadBalancing->nReplicas != rhs.loadBalancing->nReplicas) - { - return false; - } - AdaptiveLoadBalancingPolicyPtr alhs = AdaptiveLoadBalancingPolicyPtr::dynamicCast(lhs.loadBalancing); - AdaptiveLoadBalancingPolicyPtr arhs = AdaptiveLoadBalancingPolicyPtr::dynamicCast(rhs.loadBalancing); - if(alhs && arhs && alhs->loadSample != arhs->loadSample) - { - return false; - } - } - else if(lhs.loadBalancing || rhs.loadBalancing) + auto alhs = dynamic_pointer_cast<AdaptiveLoadBalancingPolicy>(lhs.loadBalancing); + auto arhs = dynamic_pointer_cast<AdaptiveLoadBalancingPolicy>(rhs.loadBalancing); + if(alhs && arhs && alhs->loadSample != arhs->loadSample) { return false; } - - return true; } -}; + else if(lhs.loadBalancing || rhs.loadBalancing) + { + return false; + } + + return true; +} template <typename GetKeyFunc, typename Seq> Seq getSeqUpdatedElts(const Seq& lseq, const Seq& rseq, GetKeyFunc func) @@ -383,7 +348,7 @@ validateProxyOptions(const Resolver& resolver, const string& proxyOptions) } -Resolver::Resolver(const ApplicationDescriptor& app, const Ice::CommunicatorPtr& communicator, bool enableWarning) : +Resolver::Resolver(const ApplicationDescriptor& app, const shared_ptr<Ice::Communicator>& communicator, bool enableWarning) : _application(&app), _communicator(communicator), _escape(false), @@ -508,7 +473,7 @@ Resolver::Resolver(const Resolver& resolve, } } -Resolver::Resolver(const InternalNodeInfoPtr& info, const Ice::CommunicatorPtr& com) : +Resolver::Resolver(const shared_ptr<InternalNodeInfo>& info, const shared_ptr<Ice::Communicator>& com) : _application(0), _communicator(com), _escape(true), @@ -1049,7 +1014,7 @@ Resolver::checkDeprecated(const string& name) const } } -CommunicatorHelper::CommunicatorHelper(const CommunicatorDescriptorPtr& desc, bool ignoreProps) : +CommunicatorHelper::CommunicatorHelper(const shared_ptr<CommunicatorDescriptor>& desc, bool ignoreProps) : _desc(desc), _ignoreProps(ignoreProps) { } @@ -1067,7 +1032,7 @@ CommunicatorHelper::operator==(const CommunicatorHelper& helper) const return false; } - if(!isSeqEqual(_desc->adapters, helper._desc->adapters, GetAdapterId(), AdapterEq())) + if(!isSeqEqual(_desc->adapters, helper._desc->adapters, getAdapterId, adapterEqual)) { return false; } @@ -1080,12 +1045,6 @@ CommunicatorHelper::operator==(const CommunicatorHelper& helper) const } } - if(set<DbEnvDescriptor>(_desc->dbEnvs.begin(), _desc->dbEnvs.end()) != - set<DbEnvDescriptor>(helper._desc->dbEnvs.begin(), helper._desc->dbEnvs.end())) - { - return false; - } - if(_desc->logs != helper._desc->logs) { return false; @@ -1143,7 +1102,7 @@ CommunicatorHelper::getReplicaGroups(set<string>& replicaGroups) const } void -CommunicatorHelper::instantiateImpl(const CommunicatorDescriptorPtr& instance, const Resolver& resolve) const +CommunicatorHelper::instantiateImpl(const shared_ptr<CommunicatorDescriptor>& instance, const Resolver& resolve) const { instance->description = resolve(_desc->description, "description"); instance->propertySet = resolve(_desc->propertySet); @@ -1200,16 +1159,6 @@ CommunicatorHelper::instantiateImpl(const CommunicatorDescriptorPtr& instance, c } } - for(DbEnvDescriptorSeq::const_iterator s = _desc->dbEnvs.begin(); s != _desc->dbEnvs.end(); ++s) - { - DbEnvDescriptor dbEnv; - dbEnv.name = resolve(s->name, "database environment name", false); - dbEnv.description = resolve(s->description, "database environment description"); - dbEnv.dbHome = resolve(s->dbHome, "database environment home directory"); - dbEnv.properties = resolve(s->properties, "database environment property"); - instance->dbEnvs.push_back(dbEnv); - } - for(Ice::StringSeq::const_iterator l = _desc->logs.begin(); l != _desc->logs.end(); ++l) { instance->logs.push_back(resolve(*l, "log path", false)); @@ -1217,7 +1166,7 @@ CommunicatorHelper::instantiateImpl(const CommunicatorDescriptorPtr& instance, c } void -CommunicatorHelper::print(const Ice::CommunicatorPtr& communicator, Output& out) const +CommunicatorHelper::print(const shared_ptr<Ice::Communicator>& communicator, Output& out) const { if(!_desc->description.empty()) { @@ -1228,12 +1177,6 @@ CommunicatorHelper::print(const Ice::CommunicatorPtr& communicator, Output& out) } set<string> hiddenProperties; { - for(DbEnvDescriptorSeq::const_iterator p = _desc->dbEnvs.begin(); p != _desc->dbEnvs.end(); ++p) - { - printDbEnv(out, *p); - } - } - { for(AdapterDescriptorSeq::const_iterator p = _desc->adapters.begin(); p != _desc->adapters.end(); ++p) { hiddenProperties.insert(p->name + ".Endpoints"); @@ -1269,36 +1212,7 @@ CommunicatorHelper::print(const Ice::CommunicatorPtr& communicator, Output& out) } void -CommunicatorHelper::printDbEnv(Output& out, const DbEnvDescriptor& dbEnv) const -{ - out << nl << "database environment `" << dbEnv.name << "'"; - if(!dbEnv.dbHome.empty() || !dbEnv.properties.empty() || !dbEnv.description.empty()) - { - out << sb; - if(!dbEnv.dbHome.empty()) - { - out << nl << "home = `" << dbEnv.dbHome << "'"; - } - if(!dbEnv.description.empty()) - { - out << nl << "description = `" << dbEnv.description << "'"; - } - if(!dbEnv.properties.empty()) - { - out << nl << "properties"; - out << sb; - for(PropertyDescriptorSeq::const_iterator p = dbEnv.properties.begin(); p != dbEnv.properties.end(); ++p) - { - out << nl << p->name << " = `" << p->value << "'"; - } - out << eb; - } - out << eb; - } -} - -void -CommunicatorHelper::printObjectAdapter(const Ice::CommunicatorPtr& communicator, +CommunicatorHelper::printObjectAdapter(const shared_ptr<Ice::Communicator>& communicator, Output& out, const AdapterDescriptor& adapter) const { @@ -1372,7 +1286,7 @@ CommunicatorHelper::getProperty(const string& name) const return IceGrid::getProperty(_desc->propertySet.properties, name); } -ServiceHelper::ServiceHelper(const ServiceDescriptorPtr& descriptor, bool ignoreProps) : +ServiceHelper::ServiceHelper(const shared_ptr<ServiceDescriptor>& descriptor, bool ignoreProps) : CommunicatorHelper(descriptor, ignoreProps), _desc(descriptor) { @@ -1400,29 +1314,23 @@ ServiceHelper::operator==(const CommunicatorHelper& h) const return true; } -bool -ServiceHelper::operator!=(const CommunicatorHelper& helper) const -{ - return !operator==(helper); -} - -ServiceDescriptorPtr +shared_ptr<ServiceDescriptor> ServiceHelper::getDescriptor() const { return _desc; } -ServiceDescriptorPtr +shared_ptr<ServiceDescriptor> ServiceHelper::instantiate(const Resolver& resolver, const PropertyDescriptorSeq& props, const PropertySetDescriptorDict& serviceProps) const { - ServiceDescriptorPtr service = new ServiceDescriptor(); + auto service = make_shared<ServiceDescriptor>(); instantiateImpl(service, resolver, props, serviceProps); return service; } void -ServiceHelper::instantiateImpl(const ServiceDescriptorPtr& instance, +ServiceHelper::instantiateImpl(const shared_ptr<ServiceDescriptor>& instance, const Resolver& resolve, const PropertyDescriptorSeq& props, const PropertySetDescriptorDict& serviceProps) const @@ -1441,7 +1349,7 @@ ServiceHelper::instantiateImpl(const ServiceDescriptorPtr& instance, } void -ServiceHelper::print(const Ice::CommunicatorPtr& communicator, Output& out) const +ServiceHelper::print(const shared_ptr<Ice::Communicator>& communicator, Output& out) const { out << "service `" + _desc->name + "'"; out << sb; @@ -1450,7 +1358,7 @@ ServiceHelper::print(const Ice::CommunicatorPtr& communicator, Output& out) cons out << eb; } -ServerHelper::ServerHelper(const ServerDescriptorPtr& descriptor, bool ignoreProps) : +ServerHelper::ServerHelper(const shared_ptr<ServerDescriptor>& descriptor, bool ignoreProps) : CommunicatorHelper(descriptor, ignoreProps), _desc(descriptor) { @@ -1525,19 +1433,13 @@ ServerHelper::operator==(const CommunicatorHelper& h) const return true; } -bool -ServerHelper::operator!=(const CommunicatorHelper& helper) const -{ - return !operator==(helper); -} - -ServerDescriptorPtr +shared_ptr<ServerDescriptor> ServerHelper::getDescriptor() const { return _desc; } -ServerDescriptorPtr +shared_ptr<ServerDescriptor> ServerHelper::instantiate(const Resolver& resolver, const PropertyDescriptorSeq& props, const PropertySetDescriptorDict& serviceProps) const @@ -1547,19 +1449,19 @@ ServerHelper::instantiate(const Resolver& resolver, resolver.exception("service property sets are only allowed in IceBox server instances"); } - ServerDescriptorPtr server = new ServerDescriptor(); + auto server = make_shared<ServerDescriptor>(); instantiateImpl(server, resolver, props); return server; } void -ServerHelper::print(const Ice::CommunicatorPtr& communicator, Output& out) const +ServerHelper::print(const shared_ptr<Ice::Communicator>& communicator, Output& out) const { print(communicator, out, ServerInfo()); } void -ServerHelper::print(const Ice::CommunicatorPtr& communicator, Output& out, const ServerInfo& info) const +ServerHelper::print(const shared_ptr<Ice::Communicator>& communicator, Output& out, const ServerInfo& info) const { out << "server `" + _desc->id + "'"; out << sb; @@ -1568,7 +1470,7 @@ ServerHelper::print(const Ice::CommunicatorPtr& communicator, Output& out, const } void -ServerHelper::printImpl(const Ice::CommunicatorPtr& communicator, Output& out, const ServerInfo& info) const +ServerHelper::printImpl(const shared_ptr<Ice::Communicator>& communicator, Output& out, const ServerInfo& info) const { if(!info.application.empty()) { @@ -1620,7 +1522,7 @@ ServerHelper::printImpl(const Ice::CommunicatorPtr& communicator, Output& out, c } void -ServerHelper::instantiateImpl(const ServerDescriptorPtr& instance, +ServerHelper::instantiateImpl(const shared_ptr<ServerDescriptor>& instance, const Resolver& resolve, const PropertyDescriptorSeq& props) const { @@ -1648,7 +1550,7 @@ ServerHelper::instantiateImpl(const ServerDescriptorPtr& instance, instance->propertySet.properties.insert(instance->propertySet.properties.end(), props.begin(), props.end()); } -IceBoxHelper::IceBoxHelper(const IceBoxDescriptorPtr& descriptor, bool ignoreProps) : +IceBoxHelper::IceBoxHelper(const shared_ptr<IceBoxDescriptor>& descriptor, bool ignoreProps) : ServerHelper(descriptor, ignoreProps), _desc(descriptor) { @@ -1675,18 +1577,12 @@ IceBoxHelper::operator==(const CommunicatorHelper& h) const return true; } -bool -IceBoxHelper::operator!=(const CommunicatorHelper& helper) const -{ - return !operator==(helper); -} - -ServerDescriptorPtr +shared_ptr<ServerDescriptor> IceBoxHelper::instantiate(const Resolver& resolver, const PropertyDescriptorSeq& props, const PropertySetDescriptorDict& serviceProps) const { - IceBoxDescriptorPtr iceBox = new IceBoxDescriptor(); + auto iceBox = make_shared<IceBoxDescriptor>(); instantiateImpl(iceBox, resolver, props, serviceProps); return iceBox; } @@ -1712,13 +1608,13 @@ IceBoxHelper::getReplicaGroups(set<string>& replicaGroups) const } void -IceBoxHelper::print(const Ice::CommunicatorPtr& communicator, Output& out) const +IceBoxHelper::print(const shared_ptr<Ice::Communicator>& communicator, Output& out) const { print(communicator, out, ServerInfo()); } void -IceBoxHelper::print(const Ice::CommunicatorPtr& communicator, Output& out, const ServerInfo& info) const +IceBoxHelper::print(const shared_ptr<Ice::Communicator>& communicator, Output& out, const ServerInfo& info) const { out << "icebox `" + _desc->id + "'"; out << sb; @@ -1738,7 +1634,7 @@ IceBoxHelper::print(const Ice::CommunicatorPtr& communicator, Output& out, const } void -IceBoxHelper::instantiateImpl(const IceBoxDescriptorPtr& instance, +IceBoxHelper::instantiateImpl(const shared_ptr<IceBoxDescriptor>& instance, const Resolver& resolver, const PropertyDescriptorSeq& props, const PropertySetDescriptorDict& serviceProps) const @@ -1864,7 +1760,7 @@ ServiceInstanceHelper::instantiate(const Resolver& resolve, const PropertySetDes { assert(!_def._cpp_template.empty()); TemplateDescriptor tmpl = resolve.getServiceTemplate(_def._cpp_template); - def = ServiceHelper(ServiceDescriptorPtr::dynamicCast(tmpl.descriptor)); + def = ServiceHelper(dynamic_pointer_cast<ServiceDescriptor>(tmpl.descriptor)); parameterValues = instantiateParams(resolve, _def._cpp_template, _def.parameterValues, @@ -1911,7 +1807,7 @@ ServiceInstanceHelper::getReplicaGroups(set<string>& replicaGroups) const } void -ServiceInstanceHelper::print(const Ice::CommunicatorPtr& communicator, Output& out) const +ServiceInstanceHelper::print(const shared_ptr<Ice::Communicator>& communicator, Output& out) const { if(_service.getDescriptor()) { @@ -1942,7 +1838,7 @@ ServerInstanceHelper::ServerInstanceHelper(const ServerInstanceDescriptor& desc, init(0, resolve, instantiate); } -ServerInstanceHelper::ServerInstanceHelper(const ServerDescriptorPtr& definition, +ServerInstanceHelper::ServerInstanceHelper(const shared_ptr<ServerDescriptor>& definition, const Resolver& resolve, bool instantiate) : _def(ServerInstanceDescriptor()) @@ -1951,12 +1847,12 @@ ServerInstanceHelper::ServerInstanceHelper(const ServerDescriptorPtr& definition } void -ServerInstanceHelper::init(const ServerDescriptorPtr& definition, const Resolver& resolve, bool instantiate) +ServerInstanceHelper::init(const shared_ptr<ServerDescriptor>& definition, const Resolver& resolve, bool instantiate) { // // Get the server definition if it's not provided. // - ServerDescriptorPtr def = definition; + auto def = definition; std::map<std::string, std::string> parameterValues; if(!def) { @@ -1969,7 +1865,7 @@ ServerInstanceHelper::init(const ServerDescriptorPtr& definition, const Resolver // Get the server definition and the template property sets. // TemplateDescriptor tmpl = resolve.getServerTemplate(_def._cpp_template); - def = ServerDescriptorPtr::dynamicCast(tmpl.descriptor); + def = dynamic_pointer_cast<ServerDescriptor>(tmpl.descriptor); parameterValues = instantiateParams(resolve, _def._cpp_template, _def.parameterValues, @@ -2025,8 +1921,8 @@ ServerInstanceHelper::init(const ServerDescriptorPtr& definition, const Resolver // // Instantiate the server definition. // - ServerDescriptorPtr inst = _serverDefinition->instantiate(svrResolve, _instance.propertySet.properties, - _instance.servicePropertySets); + shared_ptr<ServerDescriptor> inst = _serverDefinition->instantiate(svrResolve, _instance.propertySet.properties, + _instance.servicePropertySets); _serverInstance = createHelper(inst); } @@ -2072,14 +1968,14 @@ ServerInstanceHelper::getInstance() const return _instance; } -ServerDescriptorPtr +shared_ptr<ServerDescriptor> ServerInstanceHelper::getServerDefinition() const { assert(_def._cpp_template.empty()); return _serverDefinition->getDescriptor(); } -ServerDescriptorPtr +shared_ptr<ServerDescriptor> ServerInstanceHelper::getServerInstance() const { assert(_serverInstance); @@ -2214,12 +2110,12 @@ NodeHelper::diff(const NodeHelper& helper) const update.name = _name; if(_def.loadFactor != helper._def.loadFactor) { - update.loadFactor = new BoxedString(_def.loadFactor); + update.loadFactor = make_shared<BoxedString>(_def.loadFactor); } if(_def.description != helper._def.description) { - update.description = new BoxedString(_def.description); + update.description = make_shared<BoxedString>(_def.description); } update.variables = getDictUpdatedElts(helper._def.variables, _def.variables); @@ -2570,7 +2466,7 @@ NodeHelper::printDiff(Output& out, const NodeHelper& helper) const out << eb; } -ApplicationHelper::ApplicationHelper(const Ice::CommunicatorPtr& communicator, +ApplicationHelper::ApplicationHelper(const shared_ptr<Ice::Communicator>& communicator, const ApplicationDescriptor& appDesc, bool enableWarning, bool instantiate) : @@ -2609,7 +2505,7 @@ ApplicationHelper::ApplicationHelper(const Ice::CommunicatorPtr& communicator, { resolve.exception("replica group load balancing is not set"); } - desc.loadBalancing = LoadBalancingPolicyPtr::dynamicCast(r->loadBalancing->ice_clone()); + desc.loadBalancing = dynamic_pointer_cast<LoadBalancingPolicy>(r->loadBalancing->ice_clone()); desc.loadBalancing->nReplicas = resolve.asInt(r->loadBalancing->nReplicas, "replica group number of replicas"); if(desc.loadBalancing->nReplicas.empty()) @@ -2620,7 +2516,7 @@ ApplicationHelper::ApplicationHelper(const Ice::CommunicatorPtr& communicator, { resolve.exception("invalid replica group load balancing number of replicas value: inferior to 0"); } - AdaptiveLoadBalancingPolicyPtr al = AdaptiveLoadBalancingPolicyPtr::dynamicCast(desc.loadBalancing); + auto al = dynamic_pointer_cast<AdaptiveLoadBalancingPolicy>(desc.loadBalancing); if(al) { al->loadSample = resolve(al->loadSample, "replica group load sample"); @@ -2717,7 +2613,7 @@ ApplicationHelper::diff(const ApplicationHelper& helper) const updt.name = _def.name; if(_def.description != helper._def.description) { - updt.description = new BoxedString(_def.description); + updt.description = make_shared<BoxedString>(_def.description); } updt.variables = getDictUpdatedElts(helper._def.variables, _def.variables); @@ -2726,15 +2622,12 @@ ApplicationHelper::diff(const ApplicationHelper& helper) const updt.propertySets = getDictUpdatedElts(helper._def.propertySets, _def.propertySets); updt.removePropertySets = getDictRemovedElts(helper._def.propertySets, _def.propertySets); - GetReplicaGroupId rk; - ReplicaGroupEq req; - updt.replicaGroups = getSeqUpdatedEltsWithEq(helper._def.replicaGroups, _def.replicaGroups, rk, req); - updt.removeReplicaGroups = getSeqRemovedElts(helper._def.replicaGroups, _def.replicaGroups, rk); + updt.replicaGroups = getSeqUpdatedEltsWithEq(helper._def.replicaGroups, _def.replicaGroups, getReplicaGroupId, replicaGroupEqual); + updt.removeReplicaGroups = getSeqRemovedElts(helper._def.replicaGroups, _def.replicaGroups, getReplicaGroupId); - TemplateDescriptorEqual eq; - updt.serverTemplates = getDictUpdatedEltsWithEq(helper._def.serverTemplates, _def.serverTemplates, eq); + updt.serverTemplates = getDictUpdatedEltsWithEq(helper._def.serverTemplates, _def.serverTemplates, templateDescriptorEqual); updt.removeServerTemplates = getDictRemovedElts(helper._def.serverTemplates, _def.serverTemplates); - updt.serviceTemplates = getDictUpdatedEltsWithEq(helper._def.serviceTemplates, _def.serviceTemplates, eq); + updt.serviceTemplates = getDictUpdatedEltsWithEq(helper._def.serviceTemplates, _def.serviceTemplates, templateDescriptorEqual); updt.removeServiceTemplates = getDictRemovedElts(helper._def.serviceTemplates, _def.serviceTemplates); NodeHelperDict updated = getDictUpdatedElts(helper._nodes, _nodes); @@ -2749,8 +2642,8 @@ ApplicationHelper::diff(const ApplicationHelper& helper) const nodeUpdate.variables = node.variables; nodeUpdate.servers = node.servers; nodeUpdate.serverInstances = node.serverInstances; - nodeUpdate.loadFactor = new BoxedString(node.loadFactor); - nodeUpdate.description = new BoxedString(node.description); + nodeUpdate.loadFactor = make_shared<BoxedString>(node.loadFactor); + nodeUpdate.description = make_shared<BoxedString>(node.description); updt.nodes.push_back(nodeUpdate); } else @@ -2767,11 +2660,10 @@ ApplicationDescriptor ApplicationHelper::update(const ApplicationUpdateDescriptor& updt) const { ApplicationDescriptor def; - GetReplicaGroupId rg; def.name = _def.name; def.description = updt.description ? updt.description->value : _def.description; - def.replicaGroups = updateSeqElts(_def.replicaGroups, updt.replicaGroups, updt.removeReplicaGroups, rg); + def.replicaGroups = updateSeqElts(_def.replicaGroups, updt.replicaGroups, updt.removeReplicaGroups, getReplicaGroupId); def.variables = updateDictElts(_def.variables, updt.variables, updt.removeVariables); def.propertySets = updateDictElts(_def.propertySets, updt.propertySets, updt.removePropertySets); def.serverTemplates = updateDictElts(_def.serverTemplates, updt.serverTemplates, updt.removeServerTemplates); @@ -2980,15 +2872,15 @@ ApplicationHelper::print(Output& out, const ApplicationInfo& info) const { out << "default (return all endpoints)"; } - else if(RandomLoadBalancingPolicyPtr::dynamicCast(p->loadBalancing)) + else if(dynamic_pointer_cast<RandomLoadBalancingPolicy>(p->loadBalancing)) { out << "random"; } - else if(RoundRobinLoadBalancingPolicyPtr::dynamicCast(p->loadBalancing)) + else if(dynamic_pointer_cast<RoundRobinLoadBalancingPolicy>(p->loadBalancing)) { out << "round-robin"; } - else if(AdaptiveLoadBalancingPolicyPtr::dynamicCast(p->loadBalancing)) + else if(dynamic_pointer_cast<AdaptiveLoadBalancingPolicy>(p->loadBalancing)) { out << "adaptive" ; } @@ -3065,11 +2957,9 @@ ApplicationHelper::printDiff(Output& out, const ApplicationHelper& helper) const } } { - GetReplicaGroupId rk; - ReplicaGroupEq req; ReplicaGroupDescriptorSeq updated = - getSeqUpdatedEltsWithEq(helper._def.replicaGroups, _def.replicaGroups, rk, req); - Ice::StringSeq removed = getSeqRemovedElts(helper._def.replicaGroups, _def.replicaGroups, rk); + getSeqUpdatedEltsWithEq(helper._def.replicaGroups, _def.replicaGroups, getReplicaGroupId, replicaGroupEqual); + Ice::StringSeq removed = getSeqRemovedElts(helper._def.replicaGroups, _def.replicaGroups, getReplicaGroupId); if(!updated.empty() || !removed.empty()) { out << nl << "replica groups"; @@ -3105,9 +2995,8 @@ ApplicationHelper::printDiff(Output& out, const ApplicationHelper& helper) const } { - TemplateDescriptorEqual eq; TemplateDescriptorDict updated; - updated = getDictUpdatedEltsWithEq(helper._def.serverTemplates, _def.serverTemplates, eq); + updated = getDictUpdatedEltsWithEq(helper._def.serverTemplates, _def.serverTemplates, templateDescriptorEqual); Ice::StringSeq removed = getDictRemovedElts(helper._def.serverTemplates, _def.serverTemplates); if(!updated.empty() || !removed.empty()) { @@ -3135,9 +3024,8 @@ ApplicationHelper::printDiff(Output& out, const ApplicationHelper& helper) const } } { - TemplateDescriptorEqual eq; TemplateDescriptorDict updated; - updated = getDictUpdatedEltsWithEq(helper._def.serviceTemplates, _def.serviceTemplates, eq); + updated = getDictUpdatedEltsWithEq(helper._def.serviceTemplates, _def.serviceTemplates, templateDescriptorEqual); Ice::StringSeq removed = getDictRemovedElts(helper._def.serviceTemplates, _def.serviceTemplates); if(!updated.empty() || !removed.empty()) { @@ -3198,10 +3086,10 @@ ApplicationHelper::printDiff(Output& out, const ApplicationHelper& helper) const } bool -IceGrid::descriptorEqual(const ServerDescriptorPtr& lhs, const ServerDescriptorPtr& rhs, bool ignoreProps) +IceGrid::descriptorEqual(const shared_ptr<ServerDescriptor>& lhs, const shared_ptr<ServerDescriptor>& rhs, bool ignoreProps) { - IceBoxDescriptorPtr lhsIceBox = IceBoxDescriptorPtr::dynamicCast(lhs); - IceBoxDescriptorPtr rhsIceBox = IceBoxDescriptorPtr::dynamicCast(rhs); + auto lhsIceBox = dynamic_pointer_cast<IceBoxDescriptor>(lhs); + auto rhsIceBox = dynamic_pointer_cast<IceBoxDescriptor>(rhs); if(lhsIceBox && rhsIceBox) { return IceBoxHelper(lhsIceBox, ignoreProps) == IceBoxHelper(rhsIceBox, ignoreProps); @@ -3216,17 +3104,17 @@ IceGrid::descriptorEqual(const ServerDescriptorPtr& lhs, const ServerDescriptorP } } -ServerHelperPtr -IceGrid::createHelper(const ServerDescriptorPtr& desc) +shared_ptr<ServerHelper> +IceGrid::createHelper(const shared_ptr<ServerDescriptor>& desc) { - IceBoxDescriptorPtr iceBox = IceBoxDescriptorPtr::dynamicCast(desc); + auto iceBox = dynamic_pointer_cast<IceBoxDescriptor>(desc); if(iceBox) { - return new IceBoxHelper(iceBox); + return make_shared<IceBoxHelper>(iceBox); } else { - return new ServerHelper(desc); + return make_shared<ServerHelper>(desc); } } |