![]() |
Elementa v8.0.0
Minimalistic library for any C++ application (C++11 and up)
|
To declare classes that has a valid state.
Usage:
\code class YourClass: ELE_CLASS_VALIDATABLE ... \endcode
\code
class Yourclass: another class derivative of Validatable
or Validatable itself
{
...
Yourclass(const Yourclass & another):Validatable{another},
"immediate-base"{another}
{ ... }
Yourclass & operator=(const Yourclass & another)
{ if (this != &another)
{
Validatable::operator=(another);
"immediate-base"::operator=(another);
...
}
return(*this); }
};
\endcode

Classes | |
| class | elementa::patterns::Validatable |
| Any class derived from this base class gets a "valid"/"invalid" state. More... | |
Macros | |
| #define | ELE_CLASS_VALIDATABLE virtual public elementa::patterns::Validatable |
| Declare a class derived from Validatable. More... | |
| class elementa::patterns::Validatable |
Any class derived from this base class gets a "valid"/"invalid" state.
The "valid"/"invalid" state can be consulted, being "invalid" by default at the time of object creation if no argument is passed to the Validatable constructor. It can be changed further on becoming a form of the Builder pattern
Derived classes may provide public methods that admit as many args as needed to define the object as valid (it must call the setValid() method here to set the object as valid).
Definition at line 99 of file validatable.h.
Public Member Functions | |
| bool | valid (void) const noexcept |
| Public method to be used by users of the derived class. More... | |
| virtual void | checkValid (const std::string &place="") const |
| Call this method if an exception is needed when in invalid state. More... | |
Protected Member Functions | |
| Validatable (bool initvalid=false) noexcept | |
| Validatable (const Validatable &oth) | |
| Derived classes must call this base ctor if they have non-default ones. More... | |
| Validatable & | operator= (const Validatable &oth) |
| Derived classes must call this base optor if they have non-default ones. More... | |
| void | setValid (bool defval=true) noexcept |
| Derived classes can rewrite their own (hiding this, calling this). More... | |
| void | setInvalid (void) noexcept |
|
inlineprotectednoexcept |
Definition at line 119 of file validatable.h.
|
inlineprotected |
Derived classes must call this base ctor if they have non-default ones.
A default copy ctor in derived class automatically calls this one.
Definition at line 126 of file validatable.h.
|
inlinenoexcept |
Public method to be used by users of the derived class.
The derived class itself can use the valid_ member directly, plus any other protected member.
Definition at line 106 of file validatable.h.
Referenced by elementa::base::MultItImpl< Data >::to_string().
|
inlinevirtual |
Call this method if an exception is needed when in invalid state.
You can also override it if more info in the error is needed.
Definition at line 110 of file validatable.h.
References ELE_CODE_INVSTATE.
|
inlineprotected |
Derived classes must call this base optor if they have non-default ones.
A default assign optor in derived class automatically calls this one.
Definition at line 135 of file validatable.h.
Referenced by elementa::adts::graphs::Graph< Vertex, Edge >::eenteringend().
|
inlineprotectednoexcept |
Derived classes can rewrite their own (hiding this, calling this).
Definition at line 144 of file validatable.h.
|
inlineprotectednoexcept |
Definition at line 146 of file validatable.h.
| #define ELE_CLASS_VALIDATABLE virtual public elementa::patterns::Validatable |
#include <elementa/patterns/validatable.h>
Declare a class derived from Validatable.
Definition at line 82 of file validatable.h.