forked from quickfixgo/quickfix
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TestRequest.generated.go
74 lines (62 loc) · 2 KB
/
TestRequest.generated.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
package testrequest
import (
"github.com/quickfixgo/quickfix"
"github.com/quickfixgo/quickfix/field"
"github.com/quickfixgo/quickfix/fix41"
"github.com/quickfixgo/quickfix/tag"
)
//TestRequest is the fix41 TestRequest type, MsgType = 1
type TestRequest struct {
fix41.Header
*quickfix.Body
fix41.Trailer
Message *quickfix.Message
}
//FromMessage creates a TestRequest from a quickfix.Message instance
func FromMessage(m *quickfix.Message) TestRequest {
return TestRequest{
Header: fix41.Header{&m.Header},
Body: &m.Body,
Trailer: fix41.Trailer{&m.Trailer},
Message: m,
}
}
//ToMessage returns a quickfix.Message instance
func (m TestRequest) ToMessage() *quickfix.Message {
return m.Message
}
//New returns a TestRequest initialized with the required fields for TestRequest
func New(testreqid field.TestReqIDField) (m TestRequest) {
m.Message = quickfix.NewMessage()
m.Header = fix41.NewHeader(&m.Message.Header)
m.Body = &m.Message.Body
m.Trailer.Trailer = &m.Message.Trailer
m.Header.Set(field.NewMsgType("1"))
m.Set(testreqid)
return
}
//A RouteOut is the callback type that should be implemented for routing Message
type RouteOut func(msg TestRequest, sessionID quickfix.SessionID) quickfix.MessageRejectError
//Route returns the beginstring, message type, and MessageRoute for this Message type
func Route(router RouteOut) (string, string, quickfix.MessageRoute) {
r := func(msg *quickfix.Message, sessionID quickfix.SessionID) quickfix.MessageRejectError {
return router(FromMessage(msg), sessionID)
}
return "FIX.4.1", "1", r
}
//SetTestReqID sets TestReqID, Tag 112
func (m TestRequest) SetTestReqID(v string) {
m.Set(field.NewTestReqID(v))
}
//GetTestReqID gets TestReqID, Tag 112
func (m TestRequest) GetTestReqID() (v string, err quickfix.MessageRejectError) {
var f field.TestReqIDField
if err = m.Get(&f); err == nil {
v = f.Value()
}
return
}
//HasTestReqID returns true if TestReqID is present, Tag 112
func (m TestRequest) HasTestReqID() bool {
return m.Has(tag.TestReqID)
}