Class Base
Defined in File base.h
Inheritance Relationships
Base Type
public std::enable_shared_from_this< Base >
Derived Types
public mindspore::AnfNode
(Class AnfNode)public mindspore::BaseRef
(Class BaseRef)public mindspore::Value
(Class Value)public mindspore::abstract::AbstractBase
(Class AbstractBase)public mindspore::abstract::BaseShape
(Class BaseShape)
Class Documentation
-
class Base : public std::enable_shared_from_this<Base>
Base is a base class of many derived classes, which provides basic interfaces such as hash, and so on.
Subclassed by mindspore::AnfNode, mindspore::BaseRef, mindspore::Value, mindspore::abstract::AbstractBase, mindspore::abstract::BaseShape
Public Functions
-
constexpr Base() = default
The constructor of Base.
- Returns
The instance of Base.
-
inline Base(const Base &other)
The copy constructor of Base.
- Parameters
other – [in] Define another instance of Base.
- Returns
The instance of Base.
-
virtual ~Base() = default
The destructor of Base.
-
inline virtual std::size_t hash() const
Get the hash value of this object.
- Returns
The hash value.
-
inline virtual std::string ToString() const
Get the string representation of this object.
- Returns
The string representation.
-
inline virtual void dump() const
Export the string representation to the standard output stream.
-
inline virtual std::string DumpText() const
Get the text representation of this object.
- Returns
The text representation.
-
inline virtual bool IsFromTypeId(uint32_t tid) const
Judge whether this object is an instance of class with the given type id.
- Parameters
tid – [in] Define a type id.
- Returns
The result of the judgment.
-
inline virtual bool IsSameTypeId(uint32_t tid) const
Judge whether the type id of this object is same as the given type id.
- Parameters
tid – [in] Define a type id.
- Returns
The result of the judgment.
-
inline virtual std::string type_name() const
Get the type name of this object.
- Returns
The type name.
-
inline virtual uint32_t tid() const
Get the type id of this object.
- Returns
The type id.
-
template<typename T, typename std::enable_if<!is_shared_ptr<T>::value && std::is_base_of<Base, T>::value, T>::type* = nullptr>
inline bool isa() const Judge whether this object is an instance of a given class which is derived from Base.
- Returns
The result of the judgment.
-
template<typename T, typename U = typename std::enable_if<is_shared_ptr<T>::value, typename T::element_type>::type>
inline T cast() Cast a shared_ptr of this object to a given class.
- Returns
If success, a shared_ptr of the given class will be returned. Otherwise a nullptr will be returned.
Public Static Functions
-
static inline bool IsDerivedFrom(uint32_t tid) __attribute__((__always_inline__))
Judge whether this class is derived from class with the given type id.
- Parameters
tid – [in] Define a type id.
- Returns
The result of the judgment.
Public Static Attributes
-
static constexpr uint32_t kTypeId = ConstStringHash("Base")
The type id of this class.
-
constexpr Base() = default