\brief Decrease the reference count of * the object and possibly deallocate it. * * The object will automatically be deallocated once * the reference count reaches zero. */
| 27 | * the reference count reaches zero. |
| 28 | */ |
| 29 | void decRef(bool dealloc = true) const { |
| 30 | --m_refCount; |
| 31 | if (m_refCount == 0 && dealloc) { |
| 32 | delete this; |
| 33 | } else if (m_refCount < 0) { |
| 34 | throw std::runtime_error("Internal error: reference count < 0!"); |
| 35 | } |
| 36 | } |
| 37 | |
| 38 | virtual std::string toString() const = 0; |
| 39 |