@@ -381,9 +381,12 @@ class Queue {
381381
382382 bmqp::SchemaGenerator& schemaGenerator ();
383383
384- // / Return whether this Queue is valid, i.e., is associated to an
385- // / initialized queue.
386- bool isValid () const ;
384+ // / @brief Return whether this Queue is valid, i.e., is associated to an
385+ // / opened queue.
386+ // / @param reason_p The optionally specified stream that is used to report
387+ // / the reason why this Queue is not valid.
388+ // / @return bool True if this Queue is valid, false otherwise.
389+ bool isValid (bsl::ostream* reason_p = 0 ) const ;
387390
388391 // / Return whether this Queue is valid, i.e., is associated to an opened
389392 // / queue.
@@ -677,15 +680,26 @@ inline bmqp::SchemaGenerator& Queue::schemaGenerator()
677680 return d_schemaGenerator;
678681}
679682
680- inline bool Queue::isValid () const
683+ inline bool Queue::isValid (bsl::ostream* reason_p ) const
681684{
682685 const QueueState::Enum queueState = state ();
683- return ((d_handleParameters.qId () !=
684- static_cast <unsigned int >(k_INVALID_QUEUE_ID)) &&
685- (queueState == QueueState::e_OPENED ||
686- queueState == QueueState::e_PENDING ||
687- queueState == QueueState::e_REOPENING_OPN ||
688- queueState == QueueState::e_REOPENING_CFG));
686+ if (d_handleParameters.qId () ==
687+ static_cast <unsigned int >(k_INVALID_QUEUE_ID)) {
688+ if (reason_p) {
689+ (*reason_p) << " Invalid QueueId: " << d_handleParameters.qId ();
690+ }
691+ return false ; // RETURN
692+ }
693+ const bool queueStateIsValid = (queueState == QueueState::e_OPENED ||
694+ queueState == QueueState::e_PENDING ||
695+ queueState ==
696+ QueueState::e_REOPENING_OPN ||
697+ queueState == QueueState::e_REOPENING_CFG);
698+
699+ if (!queueStateIsValid && reason_p) {
700+ (*reason_p) << " Invalid queue state: " << queueState;
701+ }
702+ return queueStateIsValid;
689703}
690704
691705inline bool Queue::isOpened () const
0 commit comments