-
Notifications
You must be signed in to change notification settings - Fork 95
/
Copy pathMetaProperties.cpp
43 lines (29 loc) · 1.41 KB
/
MetaProperties.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include "TestReflectionModule.h"
#include "TestTypes.h"
#include "TestProperties.h"
using namespace ursine::meta;
int main(void)
{
MetaInitialize( UsingModule( TestModule ) );
// you can also use type meta::Type::GetFromName( "SoundEffect" ) based on a string name
Type soundEffectType = typeof( SoundEffect );
// the volume field in the SoundEffect struct
Field volumeField = soundEffectType.GetField( "volume" );
// meta data for the volume field
const MetaManager &volumeMeta = volumeField.GetMeta( );
// getting the "Range" property, then casting the variant as a Range
Range &volumeRange = volumeMeta.GetProperty( typeof( Range ) ).GetValue<Range>( );
// 0.0f
std::cout << "SoundEffect::volume [Range.min]: " << volumeRange.min << std::endl;
// 100.0f
std::cout << "SoundEffect::volume [Range.max]: " << volumeRange.max << std::endl;
// getting the "Slider" property, then casting the variant as a Slider
Slider &volumeSlider = volumeMeta.GetProperty( typeof( Slider ) ).GetValue<Slider>( );
// type representing the SlideType enum
Type sliderTypeEnumType = typeof( SliderType );
// enum representing the SliderType
const Enum &sliderTypeEnum = sliderTypeEnumType.GetEnum( );
// get the associative value of the enum
std::cout << "SoundEffect::volume [Slider.type]: " << sliderTypeEnum.GetKey( volumeSlider.type ) << std::endl;
return 0;
}