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.codec.messaging.FooterType;
14 
15 import hunt.Object;
16 import hunt.collection.Map;
17 import hunt.proton.amqp.Symbol;
18 import hunt.proton.amqp.UnsignedLong;
19 import hunt.proton.amqp.messaging.Footer;
20 import hunt.proton.codec.AbstractDescribedType;
21 import hunt.proton.codec.Decoder;
22 import hunt.proton.codec.DescribedTypeConstructor;
23 import hunt.proton.codec.EncoderImpl;
24 import std.concurrency : initOnce;
25 import hunt.Exceptions;
26 import hunt.String;
27 
28 class FooterType : AbstractDescribedType!(Footer,Map!(String,Object)) , DescribedTypeConstructor!(Footer)
29 {
30     //private static Object[] DESCRIPTORS =
31     //{
32     //    UnsignedLong.valueOf(0x0000000000000078L), Symbol.valueOf("amqp:footer:map"),
33     //};
34 
35     static Object[]  DESCRIPTORS() {
36         __gshared Object[]  inst;
37         return initOnce!inst([UnsignedLong.valueOf(0x0000000000000078L), Symbol.valueOf("amqp:footer:map")]);
38     }
39 
40    // private static UnsignedLong DESCRIPTOR = UnsignedLong.valueOf(0x0000000000000078L);
41 
42 
43     static UnsignedLong  DESCRIPTOR() {
44         __gshared UnsignedLong  inst;
45         return initOnce!inst(UnsignedLong.valueOf(0x0000000000000078L));
46     }
47 
48 
49     public this(EncoderImpl encoder)
50     {
51         super(encoder);
52     }
53 
54     override
55     public UnsignedLong getDescriptor()
56     {
57         return DESCRIPTOR;
58     }
59 
60     override
61     protected Map!(String,Object) wrap(Footer val)
62     {
63         return val.getValue();
64     }
65 
66     public Footer newInstance(Object described)
67     {
68         return new Footer( cast(Map!(String,Object)) described );
69     }
70 
71     public TypeInfo getTypeClass()
72     {
73         return typeid(Footer);
74     }
75       
76 
77     public static void register(Decoder decoder, EncoderImpl encoder)
78     {
79         FooterType type = new FooterType(encoder);
80         //implementationMissing(false);
81         foreach(Object descriptor ; DESCRIPTORS)
82         {
83             decoder.registerDynamic(descriptor, type);
84         }
85         encoder.register(type);
86     }
87 }
88