Inviwo 0.9.12-pre
Inviwo documentation
Loading...
Searching...
No Matches
inviwo::DataTraits< T, typename > Class Template Reference

A traits class for getting information about a data object. This provides a customization point if one wants to generate the information dynamically, by specializing the traits for your kind of Data: More...

#include <datatraits.h>

Static Public Member Functions

static constexpr std::string_view classIdentifier ()
 
static constexpr std::string_view dataName ()
 
static constexpr uvec3 colorCode ()
 
static Document info (const T &data)
 

Detailed Description

template<typename T, typename = void>
class inviwo::DataTraits< T, typename >

A traits class for getting information about a data object. This provides a customization point if one wants to generate the information dynamically, by specializing the traits for your kind of Data:

template <>
struct DataTraits<MyDataType> {
    static std::string_view classIdentifier() {
        static constexpr std::string_view id{"org.something.mydatatype"};
        return id;
    }
    static std::string_view dataName() {
        static constexpr std::string_view name{"MyDataType"};
        return name;
    }
    static uvec3 colorCode() {
        return uvec3{55,66,77};
    }
    static Document info(const MyDataType& data) {
         Document doc;
         doc.append("p", data.someInfo());
         return doc;
    }
};

The default behavior uses the static members "classIdentifier", "dataName", "colorCode" and "getInfo()".

Member Function Documentation

◆ classIdentifier()

template<typename T , typename = void>
static constexpr std::string_view inviwo::DataTraits< T, typename >::classIdentifier ( )
inlinestaticconstexpr

The Class Identifier has to be globally unique. Use a reverse DNS naming scheme. Example: "org.someorg.mydatatype" The default implementation will look for a static std::string / std::string_view member T::classIdentifier. In case it is not found an empty string will be returned. An empty class identifier will be considered an error in various factories.

◆ colorCode()

template<typename T , typename = void>
static constexpr uvec3 inviwo::DataTraits< T, typename >::colorCode ( )
inlinestaticconstexpr

Should return a color that will be used to identify ports of this data type The default implementation will look for a static uvec3 member T::colorCode. In case it is not found black will be returned.

◆ dataName()

template<typename T , typename = void>
static constexpr std::string_view inviwo::DataTraits< T, typename >::dataName ( )
inlinestaticconstexpr

Should return a user friendly version of the above identifier, "MyDataType" for example. Does not have to be unique, and usually shorter then the class identifier. The default implementation will look for a static std::string / std::string_view member T::dataName. In case it is not found the classIdentifier will be returned.

◆ info()

template<typename T , typename = void>
static Document inviwo::DataTraits< T, typename >::info ( const T & data)
inlinestatic

Should return a document with information describing the data. The default implementation will look for a static function Document T::getInfo(const T& data). In case it is not found a Document only containing the dataName() will be returned.

See also
Document

The documentation for this class was generated from the following file: