Inviwo  0.9.10.1
Inviwo documentation
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 std::string classIdentifier ()
 
static std::string dataName ()
 
static 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 classIdentifier() {
        return "org.something.mydatatype";
    }
    static std::string dataName() {
        return "MyDataType";
    }
    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 std::string inviwo::DataTraits< T, typename >::classIdentifier ( )
inlinestatic

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 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 uvec3 inviwo::DataTraits< T, typename >::colorCode ( )
inlinestatic

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 std::string inviwo::DataTraits< T, typename >::dataName ( )
inlinestatic

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 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: