-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathuser_data_continainer.go
110 lines (98 loc) · 2.92 KB
/
user_data_continainer.go
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
package osg
import (
"github.com/flywave/go-osg/model"
)
func checkUDCUserData(obj interface{}) bool {
udc := obj.(*model.UserDataContainer)
return udc.UserData != nil
}
func readUDCUserData(is *OsgIstream, obj interface{}) {
udc := obj.(*model.UserDataContainer)
is.Read(is.BEGINBRACKET)
ob := is.ReadObject(nil)
udc.UserData = ob
is.Read(is.ENDBRACKET)
}
func writeUDCUserData(os *OsgOstream, obj interface{}) {
udc := obj.(*model.UserDataContainer)
os.Write(os.BEGINBRACKET)
os.Write(os.CRLF)
os.Write(udc.UserData)
os.Write(os.ENDBRACKET)
os.Write(os.CRLF)
}
// descriptions
func checkUDCDescriptions(obj interface{}) bool {
udc := obj.(*model.UserDataContainer)
return len(udc.DescriptionList) > 0
}
func readUDCDescriptions(is *OsgIstream, obj interface{}) {
udc := obj.(*model.UserDataContainer)
size := is.ReadSize()
is.Read(is.BEGINBRACKET)
for i := 0; i < size; i++ {
var str string
is.ReadWrappedString(&str)
udc.DescriptionList = append(udc.DescriptionList, str)
}
is.Read(is.ENDBRACKET)
}
func writeUDCDescriptions(os *OsgOstream, obj interface{}) {
udc := obj.(*model.UserDataContainer)
os.Write(len(udc.DescriptionList))
os.Write(os.BEGINBRACKET)
os.Write(os.CRLF)
for s := range udc.DescriptionList {
os.Write(s)
os.Write(os.CRLF)
}
os.Write(os.ENDBRACKET)
os.Write(os.CRLF)
}
func checkUDCUserObjects(obj interface{}) bool {
udc := obj.(*model.UserDataContainer)
return len(udc.ObjectList) > 0
}
func readUDCUserObjects(is *OsgIstream, obj interface{}) {
udc := obj.(*model.UserDataContainer)
size := is.ReadSize()
is.Read(is.BEGINBRACKET)
for i := 0; i < size; i++ {
ob := is.ReadObject(nil)
udc.ObjectList = append(udc.ObjectList, ob)
}
is.Read(is.ENDBRACKET)
}
func writeUDCUserObjects(os *OsgOstream, obj interface{}) {
udc := obj.(*model.UserDataContainer)
os.Write(len(udc.ObjectList))
os.Write(os.BEGINBRACKET)
os.Write(os.CRLF)
for o := range udc.ObjectList {
os.Write(o)
os.Write(os.CRLF)
}
os.Write(os.ENDBRACKET)
os.Write(os.CRLF)
}
func init() {
fn := func() interface{} {
udc := model.NewUserDataContainer()
return udc
}
wrap := NewObjectWrapper("UserDataContainer", fn, "osg::UserDataContainer")
ser1 := NewStringSerializer("Name", getObjeName, setObjName)
ser2 := NewEnumSerializer("DataVariance", getDataVariance, setDataVariance)
ser2.Add("STATIC", model.STATIC)
ser2.Add("DYNAMIC", model.DYNAMIC)
ser2.Add("UNSPECIFIED", model.UNSPECIFIED)
ser3 := NewUserSerializer("UDCUserData", checkUDCUserData, readUDCUserData, writeUDCUserData)
ser4 := NewUserSerializer("UDCDescriptions", checkUDCDescriptions, readUDCDescriptions, writeUDCDescriptions)
ser5 := NewUserSerializer("UDCUserObjects", checkUDCUserObjects, readUDCUserObjects, writeUDCUserObjects)
wrap.AddSerializer(ser1, RWSTRING)
wrap.AddSerializer(ser2, RWENUM)
wrap.AddSerializer(ser3, RWUSER)
wrap.AddSerializer(ser4, RWUSER)
wrap.AddSerializer(ser5, RWUSER)
GetObjectWrapperManager().AddWrap(wrap)
}