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