|
| Interface (ValueT t=ValueT()) |
| Construct an interface from an instance of the value type. More...
|
|
| Interface (std::nullptr_t) |
|
template<typename T , std::enable_if_t< std::is_base_of< Trait< T >, T >::value > * = nullptr> |
| Interface (T t) |
| Construct an interface instance from a type that implements this interface's trait. More...
|
|
| Interface (ValueT t, const Concept *conceptImpl) |
| Constructor for a known concept. More...
|
|
| Interface (ValueT t, std::nullptr_t) |
| Constructor for DenseMapInfo's empty key and tombstone key. More...
|
|
template<typename ConcreteType, typename ValueT, typename Traits, typename BaseType, template< typename, template< typename > class > class BaseTrait>
class mlir::detail::Interface< ConcreteType, ValueT, Traits, BaseType, BaseTrait >
This class represents an abstract interface.
An interface is a simplified mechanism for attaching concept based polymorphism to a class hierarchy. An interface is comprised of two components:
- The derived interface class: This is what users interact with, and invoke methods on.
- An interface
Trait
class: This is the class that is attached to the object implementing the interface. It is the mechanism with which models are specialized.
Derived interfaces types must provide the following template types:
- ConcreteType: The CRTP derived type.
- ValueT: The opaque type the derived interface operates on. For example
Operation*
for operation interfaces, or Attribute
for attribute interfaces.
- Traits: A class that contains definitions for a 'Concept' and a 'Model' class. The 'Concept' class defines an abstract virtual interface, where as the 'Model' class implements this interface for a specific derived T type. Both of these classes must not contain non-static data. A simple example is shown below:
{c++}
struct ExampleInterfaceTraits {
virtual unsigned getNumInputs(T t) const = 0;
};
template <
typename DerivedT>
class Model {
unsigned getNumInputs(T t) const final {
return cast<DerivedT>(t).getNumInputs();
}
};
};
typename Traits::template Model< T > Model
typename Traits::Concept Concept
- BaseType: A desired base type for the interface. This is a class that provides specific functionality for the
ValueT
value. For instance the specific Op
that will wrap the Operation*
for an OpInterface
.
- BaseTrait: The base type for the interface trait. This is the base class to use for the interface trait that will be attached to each instance of
ValueT
that implements this interface.
Definition at line 71 of file InterfaceSupport.h.
template<typename ConcreteType , typename ValueT , typename Traits , typename BaseType , template< typename, template< typename > class > class BaseTrait>
template<typename T , std::enable_if_t< std::is_base_of< Trait< T >, T >::value > * = nullptr>
Construct an interface instance from a type that implements this interface's trait.
Definition at line 106 of file InterfaceSupport.h.
template<typename ConcreteType , typename ValueT , typename Traits , typename BaseType , template< typename, template< typename > class > class BaseTrait>
Support 'classof' by checking if the given object defines the concrete interface.
Definition at line 124 of file InterfaceSupport.h.