1 /*
2  * hunt-proton: AMQP Protocol library for D programming language.
3  *
4  * Copyright (C) 2018-2019 HuntLabs
5  *
6  * Website: https://www.huntlabs.net/
7  *
8  * Licensed under the Apache-2.0 License.
9  *
10  */
11 
12 
13 module hunt.proton.amqp.transport.Flow;
14 
15 import hunt.proton.amqp.transport.FrameBody;
16 import hunt.logging;
17 import hunt.proton.amqp.Binary;
18 import hunt.proton.amqp.UnsignedInteger;
19 import hunt.Object;
20 import hunt.collection.Map;
21 import hunt.collection.LinkedHashMap;
22 import hunt.Boolean;
23 
24 class Flow : FrameBody
25 {
26     private UnsignedInteger _nextIncomingId;
27     private UnsignedInteger _incomingWindow;
28     private UnsignedInteger _nextOutgoingId;
29     private UnsignedInteger _outgoingWindow;
30     private UnsignedInteger _handle;
31     private UnsignedInteger _deliveryCount;
32     private UnsignedInteger _linkCredit;
33     private UnsignedInteger _available;
34     private Boolean _drain;
35     private Boolean _echo;
36     private IObject _properties;
37 
38     this() {
39         _drain = new Boolean(false);
40         _echo = new Boolean(false);
41     }
42 
43     this(Flow other)
44     {
45         this._nextIncomingId = other._nextIncomingId;
46         this._incomingWindow = other._incomingWindow;
47         this._nextOutgoingId = other._nextOutgoingId;
48         this._outgoingWindow = other._outgoingWindow;
49         this._handle = other._handle;
50         this._deliveryCount = other._deliveryCount;
51         this._linkCredit = other._linkCredit;
52         this._available = other._available;
53         this._drain = other._drain;
54         this._echo = other._echo;
55         if (other._properties !is null)
56         {
57             this._properties = other._properties;
58         }
59     }
60 
61     public UnsignedInteger getNextIncomingId()
62     {
63         return _nextIncomingId;
64     }
65 
66     public void setNextIncomingId(UnsignedInteger nextIncomingId)
67     {
68         _nextIncomingId = nextIncomingId;
69     }
70 
71     public UnsignedInteger getIncomingWindow()
72     {
73         return _incomingWindow;
74     }
75 
76     public void setIncomingWindow(UnsignedInteger incomingWindow)
77     {
78         if( incomingWindow is null )
79         {
80             logError("the incoming-window field is mandatory");
81         }
82 
83         _incomingWindow = incomingWindow;
84     }
85 
86     public UnsignedInteger getNextOutgoingId()
87     {
88         return _nextOutgoingId;
89     }
90 
91     public void setNextOutgoingId(UnsignedInteger nextOutgoingId)
92     {
93         if( nextOutgoingId is null )
94         {
95             logError("the next-outgoing-id field is mandatory");
96         }
97 
98         _nextOutgoingId = nextOutgoingId;
99     }
100 
101     public UnsignedInteger getOutgoingWindow()
102     {
103         return _outgoingWindow;
104     }
105 
106     public void setOutgoingWindow(UnsignedInteger outgoingWindow)
107     {
108         if( outgoingWindow is null )
109         {
110             logError("the outgoing-window field is mandatory");
111         }
112 
113         _outgoingWindow = outgoingWindow;
114     }
115 
116     public UnsignedInteger getHandle()
117     {
118         return _handle;
119     }
120 
121     public void setHandle(UnsignedInteger handle)
122     {
123         _handle = handle;
124     }
125 
126     public UnsignedInteger getDeliveryCount()
127     {
128         return _deliveryCount;
129     }
130 
131     public void setDeliveryCount(UnsignedInteger deliveryCount)
132     {
133         _deliveryCount = deliveryCount;
134     }
135 
136     public UnsignedInteger getLinkCredit()
137     {
138         return _linkCredit;
139     }
140 
141     public void setLinkCredit(UnsignedInteger linkCredit)
142     {
143         _linkCredit = linkCredit;
144     }
145 
146     public UnsignedInteger getAvailable()
147     {
148         return _available;
149     }
150 
151     public void setAvailable(UnsignedInteger available)
152     {
153         _available = available;
154     }
155 
156     public Boolean getDrain()
157     {
158         return _drain;
159     }
160 
161     public void setDrain(Boolean drain)
162     {
163         _drain = drain;
164     }
165 
166     public Boolean getEcho()
167     {
168         return _echo;
169     }
170 
171     public void setEcho(Boolean echo)
172     {
173         _echo = echo;
174     }
175 
176     public IObject getProperties()
177     {
178         return _properties;
179     }
180 
181     public void setProperties(IObject properties)
182     {
183         _properties = properties;
184     }
185 
186     public void invoke(E)(FrameBodyHandler!E handler, Binary payload, E context)
187     {
188         handler.handleFlow(this, payload, context);
189     }
190 
191 
192     public FrameBody copy()
193     {
194         return new Flow(this);
195     }
196 }