File tree Expand file tree Collapse file tree 5 files changed +36
-2
lines changed
pkg/demoinfocs/sendtables Expand file tree Collapse file tree 5 files changed +36
-2
lines changed Original file line number Diff line number Diff line change @@ -314,11 +314,16 @@ func (pe *property) Name() string {
314314 return pe .entry .name
315315}
316316
317- // Value returns current value of the property.
317+ // Value returns the current value of the property.
318318func (pe * property ) Value () PropertyValue {
319319 return pe .value
320320}
321321
322+ // Type returns the data type of the property.
323+ func (pe * property ) Type () PropertyType {
324+ return PropertyType (pe .entry .prop .rawType )
325+ }
326+
322327// PropertyValueType specifies the type of a PropertyValue
323328type PropertyValueType int
324329
Original file line number Diff line number Diff line change @@ -68,3 +68,9 @@ func TestProperty_Name(t *testing.T) {
6868
6969 assert .Equal (t , "test" , prop .Name ())
7070}
71+
72+ func TestProperty_Type (t * testing.T ) {
73+ prop := property {entry : & flattenedPropEntry {prop : & sendTableProperty {rawType : 1 }}}
74+
75+ assert .Equal (t , PropTypeFloat , prop .Type ())
76+ }
Original file line number Diff line number Diff line change @@ -23,6 +23,11 @@ func (p *Property) Value() st.PropertyValue {
2323 return p .Called ().Get (0 ).(st.PropertyValue )
2424}
2525
26+ // Type is a mock-implementation of Property.Type().
27+ func (p * Property ) Type () st.PropertyType {
28+ return p .Called ().Get (0 ).(st.PropertyType )
29+ }
30+
2631// OnUpdate is a mock-implementation of Property.OnUpdate().
2732func (p * Property ) OnUpdate (handler st.PropertyUpdateHandler ) {
2833 p .Called (handler )
Original file line number Diff line number Diff line change @@ -21,6 +21,22 @@ const (
2121 propTypeInt64
2222)
2323
24+ // PropertyType identifies the data type of a property.
25+ type PropertyType int
26+
27+ // PropType constants are duplicated as publics so we don't have to convert ints to PropertyType for normal use.
28+
29+ const (
30+ PropTypeInt PropertyType = iota
31+ PropTypeFloat
32+ PropTypeVector
33+ PropTypeVectorXY
34+ PropTypeString
35+ PropTypeArray
36+ PropTypeDataTable
37+ PropTypeInt64
38+ )
39+
2440const (
2541 coordFractionalBitsMp = 5
2642 coordFractionalBitsMpLowPrecision = 3
Original file line number Diff line number Diff line change @@ -8,8 +8,10 @@ package sendtables
88type Property interface {
99 // Name returns the property's name.
1010 Name () string
11- // Value returns current value of the property.
11+ // Value returns the current value of the property.
1212 Value () PropertyValue
13+ // Type returns the data type of the property.
14+ Type () PropertyType
1315 // OnUpdate registers a handler for updates of the property's value.
1416 //
1517 // The handler will be called with the current value upon registration.
You can’t perform that action at this time.
0 commit comments