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.DeleteOnCloseType; 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.DeleteOnClose; 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 DeleteOnCloseType : AbstractDescribedType!(DeleteOnClose,List!Object) , DescribedTypeConstructor!(DeleteOnClose) 30 { 31 //private static Object[] DESCRIPTORS = 32 //{ 33 // UnsignedLong.valueOf(0x000000000000002bL), Symbol.valueOf("amqp:delete-on-close:list"), 34 //}; 35 36 // private static UnsignedLong DESCRIPTOR = UnsignedLong.valueOf(0x000000000000002bL); 37 38 39 static UnsignedLong DESCRIPTOR() { 40 __gshared UnsignedLong inst; 41 return initOnce!inst(UnsignedLong.valueOf(0x000000000000002bL)); 42 } 43 44 static Object[] DESCRIPTORS() { 45 __gshared Object[] inst; 46 return initOnce!inst([UnsignedLong.valueOf(0x000000000000002bL), Symbol.valueOf("amqp:delete-on-close: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(DeleteOnClose val) 64 { 65 return new ArrayList!Object(); 66 } 67 68 public DeleteOnClose newInstance(Object described) 69 { 70 return DeleteOnClose.getInstance(); 71 } 72 73 public TypeInfo getTypeClass() 74 { 75 return typeid(DeleteOnClose); 76 } 77 78 79 public static void register(Decoder decoder, EncoderImpl encoder) 80 { 81 DeleteOnCloseType type = new DeleteOnCloseType(encoder); 82 // implementationMissing(false); 83 foreach(Object descriptor ; DESCRIPTORS) 84 { 85 decoder.registerDynamic(descriptor, type); 86 } 87 encoder.register(type); 88 } 89 } 90