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