void the
      // dynamic_cast      
      DbgStream& ds = dynamic_cast<DbgStream&>( s );
      return ds.flush();
    }
    struct IdManip { std::string id; };
    static IdManip setId( const std::string& id ) { return { id }; }
    friend inline DbgStream& operator<< ( DbgStream& ds, const IdManip &m )
    { ds.m_msgId = m.id; return ds; }
    
    //
  private:
    std::stringstream m_buf;
    std::string       m_msgId;
    inline DbgStream& flush() {
      auto verb = s_report.get_verbosity_level();
      s_report.set_verbosity_level( xsc::common_cpp::DEBUG );
      XSC_REPORT_INFO_VERB( s_report, m_msgId, m_buf.str().c_str(), DEBUG );
      s_report.set_verbosity_level( verb );
      m_buf.str( std::string() ); // clear
      return *this;
    }
  };

  static DbgStream                       s_debug;
  static xsc::common_cpp::report_handler s_report;

  // DbgMsg() when instantiated as a temporary automatically terminates message
#ifndef NDEBUG
  struct DbgMsg {
    DbgMsg( const std::string& id )
    { NocMsg::s_debug << NocMsg::s_debug.setId( id ); }
    ~DbgMsg() { NocMsg::s_debug << NocMsg::s_debug.ends; }
    template <typename T> inline std::ostream& operator<<( T&& t )
    { return NocMsg::s_debug << std::forward<T>(t); }    
  };
#define DBG_STRIP_NDEBUG
#else
  struct DbgMsg {
    DbgMsg( const std::string& id ) {};
    template <typename T> inline NocMsg::DbgStream& operator<<( T&& )
    { return NocMsg::s_debug; }
  };
#define DBG_STRIP_NDEBUG 0 &&
#endif
};

}
}

#endif


