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