]> rtime.felk.cvut.cz Git - orte.git/commitdiff
ORTE: add support for param structure in TypeRegister
authorMartin Vajnar <martin.vajnar@gmail.com>
Thu, 25 Jul 2013 12:38:26 +0000 (14:38 +0200)
committerMartin Vajnar <martin.vajnar@gmail.com>
Thu, 25 Jul 2013 12:38:26 +0000 (14:38 +0200)
This adds support for user defined callback function processEndianness()
with processParam structure being set at Type creation and passed
to processEndianness().

The processEndianness() function is called if defined and if there is no
deserialization function and thus no other way for the user application to
know the byte order of received issue.

orte/include/orte/protos_api.h
orte/include/orte/typedefs_api.h
orte/liborte/ORTETypeRegister.c
orte/liborte/RTPSCSTReaderProc.c

index 897249fb34e52fa38bf049b7b9c6bb000acedd71..f5c9beaf6713f7b4f3969b3599c84b9b9503ef24 100644 (file)
@@ -446,7 +446,8 @@ ORTESubscriptionGetInstance(ORTESubscription *cstReader);
  */
 extern int
 ORTETypeRegisterAdd(ORTEDomain *d,const char *typeName,ORTETypeSerialize ts,
-                    ORTETypeDeserialize ds,ORTETypeGetMaxSize gms,unsigned int ms);
+                    ORTETypeDeserialize ds,ORTETypeGetMaxSize gms,
+                    unsigned int ms,ORTETypeProcessEndianness pe,void *pep);
 /**
  * ORTETypeRegisterDestroyAll - destroy all registered data types
  * @d: domain object handle
index 7d45bb9ebd8cfeabc4a34c3592bfd94631a4334b..a23292481839eba59fdcb596baf95b64a42a7ca1 100644 (file)
@@ -141,6 +141,8 @@ typedef void (*ORTETypeDeserialize)(CDR_Codec *cdrCodec, void *instance);
 
 typedef int (*ORTETypeGetMaxSize)(ORTEGetMaxSizeParam *gms, int num);
 
+typedef void (*ORTETypeProcessEndianness)(CDR_Codec *cdrCodec, void *param);
+
 /**
  * struct ORTETypeRegister - registered data type
  * @typeName: name of data type 
@@ -148,15 +150,19 @@ typedef int (*ORTETypeGetMaxSize)(ORTEGetMaxSizeParam *gms, int num);
  * @deserialize: pointer to deserialization function
  * @getMaxSize: pointer to function given maximal data length
  * @maxSize: maximal size of ser./deser. data
+ * @processEndianness: allows application to adjust some preferences according to byte order
+ * @processParam: pointer to user structure containing parameters for processEndianness
  *
  * Contains description of registered data type. See @ORTETypeRegisterAdd function for details.
  */
 typedef struct ORTETypeRegister {
-  const char             *typeName;
-  ORTETypeSerialize      serialize;
-  ORTETypeDeserialize    deserialize;
-  ORTETypeGetMaxSize     getMaxSize;
-  unsigned int          maxSize;
+  const char                  *typeName;
+  ORTETypeSerialize           serialize;
+  ORTETypeDeserialize         deserialize;
+  ORTETypeGetMaxSize          getMaxSize;
+  unsigned int                maxSize;
+  ORTETypeProcessEndianness   processEndianness;
+  void                        *processParam;
 } ORTETypeRegister;
 
 /**
index 8c6511c45a94e7fee70f6f20dc322092c1bcae7a..6741b62c0c7c3bebacc32adf6e838dd3b151ee9b 100644 (file)
@@ -53,7 +53,8 @@ ORTETypeRegisterFind(ORTEDomain *d,const char *typeName) {
 /*****************************************************************************/
 int
 ORTETypeRegisterAdd(ORTEDomain *d,const char *typeName,ORTETypeSerialize ts,
-                    ORTETypeDeserialize ds,ORTETypeGetMaxSize gms,unsigned int ms) {
+                    ORTETypeDeserialize ds,ORTETypeGetMaxSize gms,
+                    unsigned int ms,ORTETypeProcessEndianness pe,void *pep) {
   TypeNode           *tn;
   
   if (!d) 
@@ -81,6 +82,8 @@ ORTETypeRegisterAdd(ORTEDomain *d,const char *typeName,ORTETypeSerialize ts,
   tn->typeRegister.deserialize=ds;
   tn->typeRegister.getMaxSize=gms;
   tn->typeRegister.maxSize=ms;
+  tn->typeRegister.processEndianness=pe;
+  tn->typeRegister.processParam=pep;
   pthread_rwlock_unlock(&d->typeEntry.lock);    
   debug(26,3) ("ORTETypeRegisterAdd: registered type:%s\n",typeName);
   return ORTE_OK;
index 0abd3ba03069c471283e3af04384fafb83905b89..b5832b7034515f9ff4096b424370ed009865bfca 100644 (file)
@@ -228,6 +228,11 @@ CSTReaderNewData(CSTRemoteWriter *cstRemoteWriter,
       memcpy(objectEntryOID->instance,
              csChange->cdrCodec.buffer,
              max_size);
+      if(cstRemoteWriter->cstReader->typeRegister->processEndianness) {
+        cstRemoteWriter->cstReader->typeRegister->processEndianness(
+            &csChange->cdrCodec,
+            cstRemoteWriter->cstReader->typeRegister->processParam);
+      }
     }
     info.status=NEW_DATA;
     info.topic=(char*)sp->topic;