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