template <class EnumT>

struct TypeInfo

Defined at line 61 of file ../../src/ui/lib/escher/base/type_info.h

TypeInfo is intended to be used in collaboration with TypedReffable. It

is a generic class that is parameterized by an enumeration that represents

all types in a tree-shaped hierarchy (note: the total number of types in the

hierarchy cannot exceed 65).

For example, to represent a class hierarchy like:

_ Base

|_ One

|_ Two

|_ SubTwo

|_ SubSubTwo

... you would start with an enumeration of all of these classes, and then

create a TypeInfo to represent the inheritance chain of each class:

enum class ExampleTypes {

kBase = 0,

kOne = 1,

kTwo = 1

<

<

1,

kSubTwo = 1

<

<

2,

kSubSubTwo = 1

<

<

3,

};

typedef TypeInfo

<ExampleTypes

> ExampleTypeInfo;

ExampleTypeInfo base_info("Base", ExampleTypes::kBase);

ExampleTypeInfo one_info("One", ExampleTypes::kBase,

ExampleTypes::kOne);

ExampleTypeInfo two_info("Two", ExampleTypes::kBase,

ExampleTypes::kTwo);

ExampleTypeInfo sub_two_info("SubTwo", ExampleTypes::kBase,

ExampleTypes::kTwo,

ExampleTypes::kSubTwo);

ExampleTypeInfo sub_sub_two_info("SubSubTwo", ExampleTypes::kBase,

ExampleTypes::kTwo,

ExampleTypes::kSubTwo,

ExampleTypes::kSubSubTwo);

You can now verify properties of the type-hierarchy:

EXPECT_FALSE(one_info.IsKindOf(two_info));

EXPECT_FALSE(two_info.IsKindOf(sub_two_info));

EXPECT_TRUE(sub_two_info.IsKindOf(two_info));

In practice, these ExampleTypeInfos would not be stored in global variables,

but instead as static members of the corresponding class. For more details

and examples, see typed_reffable.h and type_reffable_unittest.cc.

Public Members

const char * name
const uint64_t flags

Public Methods

template <typename... Args>
void TypeInfo<EnumT> (const char * type_name, Args &&... args)

Defined at line 63 of file ../../src/ui/lib/escher/base/type_info.h

bool IsKindOf (const TypeInfo<EnumT> & base_type)

Return true if |base_type| represents a type that is the same or a base

type of the one represented by this TypeInfo. Return false otherwise.

Defined at line 75 of file ../../src/ui/lib/escher/base/type_info.h

bool operator== (const TypeInfo<EnumT> & type)

Return true if the two TypeInfos represent the same type.

Defined at line 80 of file ../../src/ui/lib/escher/base/type_info.h