diff --git a/src/groups/mqb/mqbcmd/mqbcmd.xsd b/src/groups/mqb/mqbcmd/mqbcmd.xsd index 5043e91365..e3d724c8e9 100644 --- a/src/groups/mqb/mqbcmd/mqbcmd.xsd +++ b/src/groups/mqb/mqbcmd/mqbcmd.xsd @@ -28,7 +28,7 @@ - + @@ -764,11 +764,18 @@ + + + + + + + diff --git a/src/groups/mqb/mqbcmd/mqbcmd_commandlist.cpp b/src/groups/mqb/mqbcmd/mqbcmd_commandlist.cpp index ffcd352adf..f4ff9e999b 100644 --- a/src/groups/mqb/mqbcmd/mqbcmd_commandlist.cpp +++ b/src/groups/mqb/mqbcmd/mqbcmd_commandlist.cpp @@ -65,6 +65,9 @@ struct CommandDefinition { "'count' is 'negative', print '-count' messages *preceding* the " "specified starting position. If 'count' is 'UNLIMITED', print all " "the messages starting at and after the specified position."}, + {"DOMAINS REMOVE ", + "Reject all incoming connections to all queues in domain 'name'", + "and purge them from the domain"}, {"DOMAINS RECONFIGURE ", "Reconfigure 'domain' by reloading its configuration from disk", "Reconfigure 'domain' by reloading its configuration from disk"}, diff --git a/src/groups/mqb/mqbcmd/mqbcmd_messages.cpp b/src/groups/mqb/mqbcmd/mqbcmd_messages.cpp index 3aa470d72b..b0ca1b156f 100644 --- a/src/groups/mqb/mqbcmd/mqbcmd_messages.cpp +++ b/src/groups/mqb/mqbcmd/mqbcmd_messages.cpp @@ -1582,6 +1582,242 @@ const char* DomainReconfigure::selectionName() const } } +// ------------------ +// class DomainRemove +// ------------------ + +// CONSTANTS + +const char DomainRemove::CLASS_NAME[] = "DomainRemove"; + +const bdlat_SelectionInfo DomainRemove::SELECTION_INFO_ARRAY[] = { + {SELECTION_ID_DOMAIN, + "domain", + sizeof("domain") - 1, + "", + bdlat_FormattingMode::e_TEXT}}; + +// CLASS METHODS + +const bdlat_SelectionInfo* DomainRemove::lookupSelectionInfo(const char* name, + int nameLength) +{ + for (int i = 0; i < 1; ++i) { + const bdlat_SelectionInfo& selectionInfo = + DomainRemove::SELECTION_INFO_ARRAY[i]; + + if (nameLength == selectionInfo.d_nameLength && + 0 == bsl::memcmp(selectionInfo.d_name_p, name, nameLength)) { + return &selectionInfo; + } + } + + return 0; +} + +const bdlat_SelectionInfo* DomainRemove::lookupSelectionInfo(int id) +{ + switch (id) { + case SELECTION_ID_DOMAIN: + return &SELECTION_INFO_ARRAY[SELECTION_INDEX_DOMAIN]; + default: return 0; + } +} + +// CREATORS + +DomainRemove::DomainRemove(const DomainRemove& original, + bslma::Allocator* basicAllocator) +: d_selectionId(original.d_selectionId) +, d_allocator_p(bslma::Default::allocator(basicAllocator)) +{ + switch (d_selectionId) { + case SELECTION_ID_DOMAIN: { + new (d_domain.buffer()) + bsl::string(original.d_domain.object(), d_allocator_p); + } break; + default: BSLS_ASSERT(SELECTION_ID_UNDEFINED == d_selectionId); + } +} + +#if defined(BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES) && \ + defined(BSLS_COMPILERFEATURES_SUPPORT_NOEXCEPT) +DomainRemove::DomainRemove(DomainRemove&& original) noexcept +: d_selectionId(original.d_selectionId), + d_allocator_p(original.d_allocator_p) +{ + switch (d_selectionId) { + case SELECTION_ID_DOMAIN: { + new (d_domain.buffer()) + bsl::string(bsl::move(original.d_domain.object()), d_allocator_p); + } break; + default: BSLS_ASSERT(SELECTION_ID_UNDEFINED == d_selectionId); + } +} + +DomainRemove::DomainRemove(DomainRemove&& original, + bslma::Allocator* basicAllocator) +: d_selectionId(original.d_selectionId) +, d_allocator_p(bslma::Default::allocator(basicAllocator)) +{ + switch (d_selectionId) { + case SELECTION_ID_DOMAIN: { + new (d_domain.buffer()) + bsl::string(bsl::move(original.d_domain.object()), d_allocator_p); + } break; + default: BSLS_ASSERT(SELECTION_ID_UNDEFINED == d_selectionId); + } +} +#endif + +// MANIPULATORS + +DomainRemove& DomainRemove::operator=(const DomainRemove& rhs) +{ + if (this != &rhs) { + switch (rhs.d_selectionId) { + case SELECTION_ID_DOMAIN: { + makeDomain(rhs.d_domain.object()); + } break; + default: + BSLS_ASSERT(SELECTION_ID_UNDEFINED == rhs.d_selectionId); + reset(); + } + } + + return *this; +} + +#if defined(BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES) && \ + defined(BSLS_COMPILERFEATURES_SUPPORT_NOEXCEPT) +DomainRemove& DomainRemove::operator=(DomainRemove&& rhs) +{ + if (this != &rhs) { + switch (rhs.d_selectionId) { + case SELECTION_ID_DOMAIN: { + makeDomain(bsl::move(rhs.d_domain.object())); + } break; + default: + BSLS_ASSERT(SELECTION_ID_UNDEFINED == rhs.d_selectionId); + reset(); + } + } + + return *this; +} +#endif + +void DomainRemove::reset() +{ + switch (d_selectionId) { + case SELECTION_ID_DOMAIN: { + typedef bsl::string Type; + d_domain.object().~Type(); + } break; + default: BSLS_ASSERT(SELECTION_ID_UNDEFINED == d_selectionId); + } + + d_selectionId = SELECTION_ID_UNDEFINED; +} + +int DomainRemove::makeSelection(int selectionId) +{ + switch (selectionId) { + case SELECTION_ID_DOMAIN: { + makeDomain(); + } break; + case SELECTION_ID_UNDEFINED: { + reset(); + } break; + default: return -1; + } + return 0; +} + +int DomainRemove::makeSelection(const char* name, int nameLength) +{ + const bdlat_SelectionInfo* selectionInfo = lookupSelectionInfo(name, + nameLength); + if (0 == selectionInfo) { + return -1; + } + + return makeSelection(selectionInfo->d_id); +} + +bsl::string& DomainRemove::makeDomain() +{ + if (SELECTION_ID_DOMAIN == d_selectionId) { + bdlat_ValueTypeFunctions::reset(&d_domain.object()); + } + else { + reset(); + new (d_domain.buffer()) bsl::string(d_allocator_p); + d_selectionId = SELECTION_ID_DOMAIN; + } + + return d_domain.object(); +} + +bsl::string& DomainRemove::makeDomain(const bsl::string& value) +{ + if (SELECTION_ID_DOMAIN == d_selectionId) { + d_domain.object() = value; + } + else { + reset(); + new (d_domain.buffer()) bsl::string(value, d_allocator_p); + d_selectionId = SELECTION_ID_DOMAIN; + } + + return d_domain.object(); +} + +#if defined(BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES) && \ + defined(BSLS_COMPILERFEATURES_SUPPORT_NOEXCEPT) +bsl::string& DomainRemove::makeDomain(bsl::string&& value) +{ + if (SELECTION_ID_DOMAIN == d_selectionId) { + d_domain.object() = bsl::move(value); + } + else { + reset(); + new (d_domain.buffer()) bsl::string(bsl::move(value), d_allocator_p); + d_selectionId = SELECTION_ID_DOMAIN; + } + + return d_domain.object(); +} +#endif + +// ACCESSORS + +bsl::ostream& +DomainRemove::print(bsl::ostream& stream, int level, int spacesPerLevel) const +{ + bslim::Printer printer(&stream, level, spacesPerLevel); + printer.start(); + switch (d_selectionId) { + case SELECTION_ID_DOMAIN: { + printer.printAttribute("domain", d_domain.object()); + } break; + default: stream << "SELECTION UNDEFINED\n"; + } + printer.end(); + return stream; +} + +const char* DomainRemove::selectionName() const +{ + switch (d_selectionId) { + case SELECTION_ID_DOMAIN: + return SELECTION_INFO_ARRAY[SELECTION_INDEX_DOMAIN].name(); + default: + BSLS_ASSERT(SELECTION_ID_UNDEFINED == d_selectionId); + return "(* UNDEFINED *)"; + } +} + // ------------------ // class ElectorState // ------------------ @@ -19777,6 +20013,11 @@ const bdlat_SelectionInfo DomainsCommand::SELECTION_INFO_ARRAY[] = { sizeof("domain") - 1, "", bdlat_FormattingMode::e_DEFAULT}, + {SELECTION_ID_REMOVE, + "remove", + sizeof("remove") - 1, + "", + bdlat_FormattingMode::e_DEFAULT}, {SELECTION_ID_RESOLVER, "resolver", sizeof("resolver") - 1, @@ -19793,7 +20034,7 @@ const bdlat_SelectionInfo DomainsCommand::SELECTION_INFO_ARRAY[] = { const bdlat_SelectionInfo* DomainsCommand::lookupSelectionInfo(const char* name, int nameLength) { - for (int i = 0; i < 3; ++i) { + for (int i = 0; i < 4; ++i) { const bdlat_SelectionInfo& selectionInfo = DomainsCommand::SELECTION_INFO_ARRAY[i]; @@ -19811,6 +20052,8 @@ const bdlat_SelectionInfo* DomainsCommand::lookupSelectionInfo(int id) switch (id) { case SELECTION_ID_DOMAIN: return &SELECTION_INFO_ARRAY[SELECTION_INDEX_DOMAIN]; + case SELECTION_ID_REMOVE: + return &SELECTION_INFO_ARRAY[SELECTION_INDEX_REMOVE]; case SELECTION_ID_RESOLVER: return &SELECTION_INFO_ARRAY[SELECTION_INDEX_RESOLVER]; case SELECTION_ID_RECONFIGURE: @@ -19831,6 +20074,10 @@ DomainsCommand::DomainsCommand(const DomainsCommand& original, new (d_domain.buffer()) Domain(original.d_domain.object(), d_allocator_p); } break; + case SELECTION_ID_REMOVE: { + new (d_remove.buffer()) + DomainRemove(original.d_remove.object(), d_allocator_p); + } break; case SELECTION_ID_RESOLVER: { new (d_resolver.buffer()) DomainResolverCommand(original.d_resolver.object(), d_allocator_p); @@ -19854,6 +20101,10 @@ DomainsCommand::DomainsCommand(DomainsCommand&& original) noexcept new (d_domain.buffer()) Domain(bsl::move(original.d_domain.object()), d_allocator_p); } break; + case SELECTION_ID_REMOVE: { + new (d_remove.buffer()) + DomainRemove(bsl::move(original.d_remove.object()), d_allocator_p); + } break; case SELECTION_ID_RESOLVER: { new (d_resolver.buffer()) DomainResolverCommand(bsl::move(original.d_resolver.object()), @@ -19878,6 +20129,10 @@ DomainsCommand::DomainsCommand(DomainsCommand&& original, new (d_domain.buffer()) Domain(bsl::move(original.d_domain.object()), d_allocator_p); } break; + case SELECTION_ID_REMOVE: { + new (d_remove.buffer()) + DomainRemove(bsl::move(original.d_remove.object()), d_allocator_p); + } break; case SELECTION_ID_RESOLVER: { new (d_resolver.buffer()) DomainResolverCommand(bsl::move(original.d_resolver.object()), @@ -19902,6 +20157,9 @@ DomainsCommand& DomainsCommand::operator=(const DomainsCommand& rhs) case SELECTION_ID_DOMAIN: { makeDomain(rhs.d_domain.object()); } break; + case SELECTION_ID_REMOVE: { + makeRemove(rhs.d_remove.object()); + } break; case SELECTION_ID_RESOLVER: { makeResolver(rhs.d_resolver.object()); } break; @@ -19926,6 +20184,9 @@ DomainsCommand& DomainsCommand::operator=(DomainsCommand&& rhs) case SELECTION_ID_DOMAIN: { makeDomain(bsl::move(rhs.d_domain.object())); } break; + case SELECTION_ID_REMOVE: { + makeRemove(bsl::move(rhs.d_remove.object())); + } break; case SELECTION_ID_RESOLVER: { makeResolver(bsl::move(rhs.d_resolver.object())); } break; @@ -19948,6 +20209,9 @@ void DomainsCommand::reset() case SELECTION_ID_DOMAIN: { d_domain.object().~Domain(); } break; + case SELECTION_ID_REMOVE: { + d_remove.object().~DomainRemove(); + } break; case SELECTION_ID_RESOLVER: { d_resolver.object().~DomainResolverCommand(); } break; @@ -19966,6 +20230,9 @@ int DomainsCommand::makeSelection(int selectionId) case SELECTION_ID_DOMAIN: { makeDomain(); } break; + case SELECTION_ID_REMOVE: { + makeRemove(); + } break; case SELECTION_ID_RESOLVER: { makeResolver(); } break; @@ -20036,6 +20303,51 @@ Domain& DomainsCommand::makeDomain(Domain&& value) } #endif +DomainRemove& DomainsCommand::makeRemove() +{ + if (SELECTION_ID_REMOVE == d_selectionId) { + bdlat_ValueTypeFunctions::reset(&d_remove.object()); + } + else { + reset(); + new (d_remove.buffer()) DomainRemove(d_allocator_p); + d_selectionId = SELECTION_ID_REMOVE; + } + + return d_remove.object(); +} + +DomainRemove& DomainsCommand::makeRemove(const DomainRemove& value) +{ + if (SELECTION_ID_REMOVE == d_selectionId) { + d_remove.object() = value; + } + else { + reset(); + new (d_remove.buffer()) DomainRemove(value, d_allocator_p); + d_selectionId = SELECTION_ID_REMOVE; + } + + return d_remove.object(); +} + +#if defined(BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES) && \ + defined(BSLS_COMPILERFEATURES_SUPPORT_NOEXCEPT) +DomainRemove& DomainsCommand::makeRemove(DomainRemove&& value) +{ + if (SELECTION_ID_REMOVE == d_selectionId) { + d_remove.object() = bsl::move(value); + } + else { + reset(); + new (d_remove.buffer()) DomainRemove(bsl::move(value), d_allocator_p); + d_selectionId = SELECTION_ID_REMOVE; + } + + return d_remove.object(); +} +#endif + DomainResolverCommand& DomainsCommand::makeResolver() { if (SELECTION_ID_RESOLVER == d_selectionId) { @@ -20143,6 +20455,9 @@ bsl::ostream& DomainsCommand::print(bsl::ostream& stream, case SELECTION_ID_DOMAIN: { printer.printAttribute("domain", d_domain.object()); } break; + case SELECTION_ID_REMOVE: { + printer.printAttribute("remove", d_remove.object()); + } break; case SELECTION_ID_RESOLVER: { printer.printAttribute("resolver", d_resolver.object()); } break; @@ -20160,6 +20475,8 @@ const char* DomainsCommand::selectionName() const switch (d_selectionId) { case SELECTION_ID_DOMAIN: return SELECTION_INFO_ARRAY[SELECTION_INDEX_DOMAIN].name(); + case SELECTION_ID_REMOVE: + return SELECTION_INFO_ARRAY[SELECTION_INDEX_REMOVE].name(); case SELECTION_ID_RESOLVER: return SELECTION_INFO_ARRAY[SELECTION_INDEX_RESOLVER].name(); case SELECTION_ID_RECONFIGURE: @@ -30528,10 +30845,3 @@ const char* InternalResult::selectionName() const // GENERATED BY @BLP_BAS_CODEGEN_VERSION@ // USING bas_codegen.pl -m msg --noAggregateConversion --noExternalization // --noIdent --package mqbcmd --msgComponent messages mqbcmd.xsd -// ---------------------------------------------------------------------------- -// NOTICE: -// Copyright 2024 Bloomberg Finance L.P. All rights reserved. -// Property of Bloomberg Finance L.P. (BFLP) -// This software is made available solely pursuant to the -// terms of a BFLP license agreement which governs its use. -// ------------------------------- END-OF-FILE -------------------------------- diff --git a/src/groups/mqb/mqbcmd/mqbcmd_messages.h b/src/groups/mqb/mqbcmd/mqbcmd_messages.h index dc74ae83dd..99c6589027 100644 --- a/src/groups/mqb/mqbcmd/mqbcmd_messages.h +++ b/src/groups/mqb/mqbcmd/mqbcmd_messages.h @@ -95,6 +95,9 @@ namespace mqbcmd { class DomainReconfigure; } namespace mqbcmd { +class DomainRemove; +} +namespace mqbcmd { class Error; } namespace mqbcmd { @@ -2758,6 +2761,221 @@ BDLAT_DECL_CHOICE_WITH_ALLOCATOR_BITWISEMOVEABLE_TRAITS( namespace mqbcmd { +// ================== +// class DomainRemove +// ================== + +class DomainRemove { + // INSTANCE DATA + union { + bsls::ObjectBuffer d_domain; + }; + + int d_selectionId; + bslma::Allocator* d_allocator_p; + + // PRIVATE ACCESSORS + template + void hashAppendImpl(t_HASH_ALGORITHM& hashAlgorithm) const; + + bool isEqualTo(const DomainRemove& rhs) const; + + public: + // TYPES + + enum { SELECTION_ID_UNDEFINED = -1, SELECTION_ID_DOMAIN = 0 }; + + enum { NUM_SELECTIONS = 1 }; + + enum { SELECTION_INDEX_DOMAIN = 0 }; + + // CONSTANTS + static const char CLASS_NAME[]; + + static const bdlat_SelectionInfo SELECTION_INFO_ARRAY[]; + + // CLASS METHODS + static const bdlat_SelectionInfo* lookupSelectionInfo(int id); + // Return selection information for the selection indicated by the + // specified 'id' if the selection exists, and 0 otherwise. + + static const bdlat_SelectionInfo* lookupSelectionInfo(const char* name, + int nameLength); + // Return selection information for the selection indicated by the + // specified 'name' of the specified 'nameLength' if the selection + // exists, and 0 otherwise. + + // CREATORS + explicit DomainRemove(bslma::Allocator* basicAllocator = 0); + // Create an object of type 'DomainRemove' having the default value. + // Use the optionally specified 'basicAllocator' to supply memory. If + // 'basicAllocator' is 0, the currently installed default allocator is + // used. + + DomainRemove(const DomainRemove& original, + bslma::Allocator* basicAllocator = 0); + // Create an object of type 'DomainRemove' having the value of the + // specified 'original' object. Use the optionally specified + // 'basicAllocator' to supply memory. If 'basicAllocator' is 0, the + // currently installed default allocator is used. + +#if defined(BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES) && \ + defined(BSLS_COMPILERFEATURES_SUPPORT_NOEXCEPT) + DomainRemove(DomainRemove&& original) noexcept; + // Create an object of type 'DomainRemove' having the value of the + // specified 'original' object. After performing this action, the + // 'original' object will be left in a valid, but unspecified state. + + DomainRemove(DomainRemove&& original, bslma::Allocator* basicAllocator); + // Create an object of type 'DomainRemove' having the value of the + // specified 'original' object. After performing this action, the + // 'original' object will be left in a valid, but unspecified state. + // Use the optionally specified 'basicAllocator' to supply memory. If + // 'basicAllocator' is 0, the currently installed default allocator is + // used. +#endif + + ~DomainRemove(); + // Destroy this object. + + // MANIPULATORS + DomainRemove& operator=(const DomainRemove& rhs); + // Assign to this object the value of the specified 'rhs' object. + +#if defined(BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES) && \ + defined(BSLS_COMPILERFEATURES_SUPPORT_NOEXCEPT) + DomainRemove& operator=(DomainRemove&& rhs); + // Assign to this object the value of the specified 'rhs' object. + // After performing this action, the 'rhs' object will be left in a + // valid, but unspecified state. +#endif + + void reset(); + // Reset this object to the default value (i.e., its value upon default + // construction). + + int makeSelection(int selectionId); + // Set the value of this object to be the default for the selection + // indicated by the specified 'selectionId'. Return 0 on success, and + // non-zero value otherwise (i.e., the selection is not found). + + int makeSelection(const char* name, int nameLength); + // Set the value of this object to be the default for the selection + // indicated by the specified 'name' of the specified 'nameLength'. + // Return 0 on success, and non-zero value otherwise (i.e., the + // selection is not found). + + bsl::string& makeDomain(); + bsl::string& makeDomain(const bsl::string& value); +#if defined(BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES) && \ + defined(BSLS_COMPILERFEATURES_SUPPORT_NOEXCEPT) + bsl::string& makeDomain(bsl::string&& value); +#endif + // Set the value of this object to be a "Domain" value. Optionally + // specify the 'value' of the "Domain". If 'value' is not specified, + // the default "Domain" value is used. + + template + int manipulateSelection(t_MANIPULATOR& manipulator); + // Invoke the specified 'manipulator' on the address of the modifiable + // selection, supplying 'manipulator' with the corresponding selection + // information structure. Return the value returned from the + // invocation of 'manipulator' if this object has a defined selection, + // and -1 otherwise. + + bsl::string& domain(); + // Return a reference to the modifiable "Domain" selection of this + // object if "Domain" is the current selection. The behavior is + // undefined unless "Domain" is the selection of this object. + + // ACCESSORS + bsl::ostream& + print(bsl::ostream& stream, int level = 0, int spacesPerLevel = 4) const; + // Format this object to the specified output 'stream' at the + // optionally specified indentation 'level' and return a reference to + // the modifiable 'stream'. If 'level' is specified, optionally + // specify 'spacesPerLevel', the number of spaces per indentation level + // for this and all of its nested objects. Each line is indented by + // the absolute value of 'level * spacesPerLevel'. If 'level' is + // negative, suppress indentation of the first line. If + // 'spacesPerLevel' is negative, suppress line breaks and format the + // entire output on one line. If 'stream' is initially invalid, this + // operation has no effect. Note that a trailing newline is provided + // in multiline mode only. + + int selectionId() const; + // Return the id of the current selection if the selection is defined, + // and -1 otherwise. + + template + int accessSelection(t_ACCESSOR& accessor) const; + // Invoke the specified 'accessor' on the non-modifiable selection, + // supplying 'accessor' with the corresponding selection information + // structure. Return the value returned from the invocation of + // 'accessor' if this object has a defined selection, and -1 otherwise. + + const bsl::string& domain() const; + // Return a reference to the non-modifiable "Domain" selection of this + // object if "Domain" is the current selection. The behavior is + // undefined unless "Domain" is the selection of this object. + + bool isDomainValue() const; + // Return 'true' if the value of this object is a "Domain" value, and + // return 'false' otherwise. + + bool isUndefinedValue() const; + // Return 'true' if the value of this object is undefined, and 'false' + // otherwise. + + const char* selectionName() const; + // Return the symbolic name of the current selection of this object. + + // HIDDEN FRIENDS + friend bool operator==(const DomainRemove& lhs, const DomainRemove& rhs) + // Return 'true' if the specified 'lhs' and 'rhs' objects have the same + // value, and 'false' otherwise. Two 'DomainRemove' objects have the + // same value if either the selections in both objects have the same + // ids and the same values, or both selections are undefined. + { + return lhs.isEqualTo(rhs); + } + + friend bool operator!=(const DomainRemove& lhs, const DomainRemove& rhs) + // Return 'true' if the specified 'lhs' and 'rhs' objects do not have + // the same values, as determined by 'operator==', and 'false' + // otherwise. + { + return !(lhs == rhs); + } + + friend bsl::ostream& operator<<(bsl::ostream& stream, + const DomainRemove& rhs) + // Format the specified 'rhs' to the specified output 'stream' and + // return a reference to the modifiable 'stream'. + { + return rhs.print(stream, 0, -1); + } + + template + friend void hashAppend(t_HASH_ALGORITHM& hashAlg, + const DomainRemove& object) + // Pass the specified 'object' to the specified 'hashAlg'. This + // function integrates with the 'bslh' modular hashing system and + // effectively provides a 'bsl::hash' specialization for + // 'DomainRemove'. + { + return object.hashAppendImpl(hashAlg); + } +}; + +} // close package namespace + +// TRAITS + +BDLAT_DECL_CHOICE_WITH_ALLOCATOR_BITWISEMOVEABLE_TRAITS(mqbcmd::DomainRemove) + +namespace mqbcmd { + // ================== // class ElectorState // ================== @@ -23848,6 +24066,7 @@ class DomainsCommand { // INSTANCE DATA union { bsls::ObjectBuffer d_domain; + bsls::ObjectBuffer d_remove; bsls::ObjectBuffer d_resolver; bsls::ObjectBuffer d_reconfigure; }; @@ -23867,16 +24086,18 @@ class DomainsCommand { enum { SELECTION_ID_UNDEFINED = -1, SELECTION_ID_DOMAIN = 0, - SELECTION_ID_RESOLVER = 1, - SELECTION_ID_RECONFIGURE = 2 + SELECTION_ID_REMOVE = 1, + SELECTION_ID_RESOLVER = 2, + SELECTION_ID_RECONFIGURE = 3 }; - enum { NUM_SELECTIONS = 3 }; + enum { NUM_SELECTIONS = 4 }; enum { SELECTION_INDEX_DOMAIN = 0, - SELECTION_INDEX_RESOLVER = 1, - SELECTION_INDEX_RECONFIGURE = 2 + SELECTION_INDEX_REMOVE = 1, + SELECTION_INDEX_RESOLVER = 2, + SELECTION_INDEX_RECONFIGURE = 3 }; // CONSTANTS @@ -23966,6 +24187,16 @@ class DomainsCommand { // specify the 'value' of the "Domain". If 'value' is not specified, // the default "Domain" value is used. + DomainRemove& makeRemove(); + DomainRemove& makeRemove(const DomainRemove& value); +#if defined(BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES) && \ + defined(BSLS_COMPILERFEATURES_SUPPORT_NOEXCEPT) + DomainRemove& makeRemove(DomainRemove&& value); +#endif + // Set the value of this object to be a "Remove" value. Optionally + // specify the 'value' of the "Remove". If 'value' is not specified, + // the default "Remove" value is used. + DomainResolverCommand& makeResolver(); DomainResolverCommand& makeResolver(const DomainResolverCommand& value); #if defined(BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES) && \ @@ -23999,6 +24230,11 @@ class DomainsCommand { // object if "Domain" is the current selection. The behavior is // undefined unless "Domain" is the selection of this object. + DomainRemove& remove(); + // Return a reference to the modifiable "Remove" selection of this + // object if "Remove" is the current selection. The behavior is + // undefined unless "Remove" is the selection of this object. + DomainResolverCommand& resolver(); // Return a reference to the modifiable "Resolver" selection of this // object if "Resolver" is the current selection. The behavior is @@ -24040,6 +24276,11 @@ class DomainsCommand { // object if "Domain" is the current selection. The behavior is // undefined unless "Domain" is the selection of this object. + const DomainRemove& remove() const; + // Return a reference to the non-modifiable "Remove" selection of this + // object if "Remove" is the current selection. The behavior is + // undefined unless "Remove" is the selection of this object. + const DomainResolverCommand& resolver() const; // Return a reference to the non-modifiable "Resolver" selection of // this object if "Resolver" is the current selection. The behavior is @@ -24054,6 +24295,10 @@ class DomainsCommand { // Return 'true' if the value of this object is a "Domain" value, and // return 'false' otherwise. + bool isRemoveValue() const; + // Return 'true' if the value of this object is a "Remove" value, and + // return 'false' otherwise. + bool isResolverValue() const; // Return 'true' if the value of this object is a "Resolver" value, and // return 'false' otherwise. @@ -33209,6 +33454,107 @@ inline bool DomainReconfigure::isUndefinedValue() const return SELECTION_ID_UNDEFINED == d_selectionId; } +// ------------------ +// class DomainRemove +// ------------------ + +// CLASS METHODS +// PRIVATE ACCESSORS +template +void DomainRemove::hashAppendImpl(t_HASH_ALGORITHM& hashAlgorithm) const +{ + typedef DomainRemove Class; + using bslh::hashAppend; + hashAppend(hashAlgorithm, this->selectionId()); + switch (this->selectionId()) { + case Class::SELECTION_ID_DOMAIN: + hashAppend(hashAlgorithm, this->domain()); + break; + default: BSLS_ASSERT(this->selectionId() == Class::SELECTION_ID_UNDEFINED); + } +} + +inline bool DomainRemove::isEqualTo(const DomainRemove& rhs) const +{ + typedef DomainRemove Class; + if (this->selectionId() == rhs.selectionId()) { + switch (rhs.selectionId()) { + case Class::SELECTION_ID_DOMAIN: return this->domain() == rhs.domain(); + default: + BSLS_ASSERT(Class::SELECTION_ID_UNDEFINED == rhs.selectionId()); + return true; + } + } + else { + return false; + } +} + +// CREATORS +inline DomainRemove::DomainRemove(bslma::Allocator* basicAllocator) +: d_selectionId(SELECTION_ID_UNDEFINED) +, d_allocator_p(bslma::Default::allocator(basicAllocator)) +{ +} + +inline DomainRemove::~DomainRemove() +{ + reset(); +} + +// MANIPULATORS +template +int DomainRemove::manipulateSelection(t_MANIPULATOR& manipulator) +{ + switch (d_selectionId) { + case DomainRemove::SELECTION_ID_DOMAIN: + return manipulator(&d_domain.object(), + SELECTION_INFO_ARRAY[SELECTION_INDEX_DOMAIN]); + default: + BSLS_ASSERT(DomainRemove::SELECTION_ID_UNDEFINED == d_selectionId); + return -1; + } +} + +inline bsl::string& DomainRemove::domain() +{ + BSLS_ASSERT(SELECTION_ID_DOMAIN == d_selectionId); + return d_domain.object(); +} + +// ACCESSORS +inline int DomainRemove::selectionId() const +{ + return d_selectionId; +} + +template +int DomainRemove::accessSelection(t_ACCESSOR& accessor) const +{ + switch (d_selectionId) { + case SELECTION_ID_DOMAIN: + return accessor(d_domain.object(), + SELECTION_INFO_ARRAY[SELECTION_INDEX_DOMAIN]); + default: BSLS_ASSERT(SELECTION_ID_UNDEFINED == d_selectionId); return -1; + } +} + +inline const bsl::string& DomainRemove::domain() const +{ + BSLS_ASSERT(SELECTION_ID_DOMAIN == d_selectionId); + return d_domain.object(); +} + +inline bool DomainRemove::isDomainValue() const +{ + return SELECTION_ID_DOMAIN == d_selectionId; +} + +inline bool DomainRemove::isUndefinedValue() const +{ + return SELECTION_ID_UNDEFINED == d_selectionId; +} + // ------------------ // class ElectorState // ------------------ @@ -48473,6 +48819,9 @@ void DomainsCommand::hashAppendImpl(t_HASH_ALGORITHM& hashAlgorithm) const case Class::SELECTION_ID_DOMAIN: hashAppend(hashAlgorithm, this->domain()); break; + case Class::SELECTION_ID_REMOVE: + hashAppend(hashAlgorithm, this->remove()); + break; case Class::SELECTION_ID_RESOLVER: hashAppend(hashAlgorithm, this->resolver()); break; @@ -48489,6 +48838,7 @@ inline bool DomainsCommand::isEqualTo(const DomainsCommand& rhs) const if (this->selectionId() == rhs.selectionId()) { switch (rhs.selectionId()) { case Class::SELECTION_ID_DOMAIN: return this->domain() == rhs.domain(); + case Class::SELECTION_ID_REMOVE: return this->remove() == rhs.remove(); case Class::SELECTION_ID_RESOLVER: return this->resolver() == rhs.resolver(); case Class::SELECTION_ID_RECONFIGURE: @@ -48523,6 +48873,9 @@ int DomainsCommand::manipulateSelection(t_MANIPULATOR& manipulator) case DomainsCommand::SELECTION_ID_DOMAIN: return manipulator(&d_domain.object(), SELECTION_INFO_ARRAY[SELECTION_INDEX_DOMAIN]); + case DomainsCommand::SELECTION_ID_REMOVE: + return manipulator(&d_remove.object(), + SELECTION_INFO_ARRAY[SELECTION_INDEX_REMOVE]); case DomainsCommand::SELECTION_ID_RESOLVER: return manipulator(&d_resolver.object(), SELECTION_INFO_ARRAY[SELECTION_INDEX_RESOLVER]); @@ -48541,6 +48894,12 @@ inline Domain& DomainsCommand::domain() return d_domain.object(); } +inline DomainRemove& DomainsCommand::remove() +{ + BSLS_ASSERT(SELECTION_ID_REMOVE == d_selectionId); + return d_remove.object(); +} + inline DomainResolverCommand& DomainsCommand::resolver() { BSLS_ASSERT(SELECTION_ID_RESOLVER == d_selectionId); @@ -48566,6 +48925,9 @@ int DomainsCommand::accessSelection(t_ACCESSOR& accessor) const case SELECTION_ID_DOMAIN: return accessor(d_domain.object(), SELECTION_INFO_ARRAY[SELECTION_INDEX_DOMAIN]); + case SELECTION_ID_REMOVE: + return accessor(d_remove.object(), + SELECTION_INFO_ARRAY[SELECTION_INDEX_REMOVE]); case SELECTION_ID_RESOLVER: return accessor(d_resolver.object(), SELECTION_INFO_ARRAY[SELECTION_INDEX_RESOLVER]); @@ -48582,6 +48944,12 @@ inline const Domain& DomainsCommand::domain() const return d_domain.object(); } +inline const DomainRemove& DomainsCommand::remove() const +{ + BSLS_ASSERT(SELECTION_ID_REMOVE == d_selectionId); + return d_remove.object(); +} + inline const DomainResolverCommand& DomainsCommand::resolver() const { BSLS_ASSERT(SELECTION_ID_RESOLVER == d_selectionId); @@ -48599,6 +48967,11 @@ inline bool DomainsCommand::isDomainValue() const return SELECTION_ID_DOMAIN == d_selectionId; } +inline bool DomainsCommand::isRemoveValue() const +{ + return SELECTION_ID_REMOVE == d_selectionId; +} + inline bool DomainsCommand::isResolverValue() const { return SELECTION_ID_RESOLVER == d_selectionId; diff --git a/src/groups/mqb/mqbcmd/mqbcmd_parseutil.cpp b/src/groups/mqb/mqbcmd/mqbcmd_parseutil.cpp index f479947706..4e90c9e02a 100644 --- a/src/groups/mqb/mqbcmd/mqbcmd_parseutil.cpp +++ b/src/groups/mqb/mqbcmd/mqbcmd_parseutil.cpp @@ -197,6 +197,7 @@ DEF_FUNC(DomainQueuePurge, QueueCommand); DEF_FUNC(DomainQueueList, ListMessages); DEF_FUNC(DomainReconfigure, DomainReconfigure); DEF_FUNC(DomainResolver, DomainResolverCommand); +DEF_FUNC(DomainRemove, DomainRemove); DEF_FUNC(ConfigProvider, ConfigProviderCommand); DEF_FUNC(Stat, StatCommand); DEF_FUNC(BrokerConfig, BrokerConfigCommand); @@ -375,6 +376,11 @@ int parseDomainsCommand(DomainsCommand* domains, error, next); // RETURN } + else if (equalCaseless(word, "REMOVE")) { + return parseDomainRemove(&domains->makeRemove(), + error, + next); // RETURN + } *error = errorCommon; *error += ", but the following was given: " + word; @@ -564,6 +570,23 @@ int parseDomainReconfigure(DomainReconfigure* reconfigure, return expectEnd(error, next); } +/// ... REMOVE ... +int parseDomainRemove(DomainRemove* remove, + bsl::string* error, + WordGenerator next) +{ + const bslstl::StringRef domain = next(); + + if (domain.empty()) { + *error = "DOMAINS REMOVE command must be followed by a " + "domain name."; + return -1; // RETURN + } + remove->makeDomain(domain); + + return expectEnd(error, next); +} + /// ... CACHE_CLEAR ... int parseClearCache(ClearCache* clear, bsl::string* error,