00001 #include <j2k/Fred/Basic.hpp>
00002 #include <j2k/Fred/Boolean.hpp>
00003 #include <j2k/Fred/StdTypes.hpp>
00004 #include <j2k/Fred/Serialize.hpp>
00005
00006 #include <j2k/Fred/Object.hpp>
00007
00008
00009 #define MAX_SERIAL_CHAR 4
00010 #define SER_ALPHA_MASK 0x01FFFFFF
00011 #define SER_INFO_MASK 0xFE000000
00012
00013
00014 #define MSG_DATA_SERIAL 0x80C94630
00015
00016 #define _IS_MSG_DATA 0x80000000
00017 #define _IS_TYPE1 0x40000000
00018 #define _IS_TYPE2 0x20000000
00019 #define _IS_TYPE3 0x10000000
00020 #define _IS_TYPE4 0x08000000
00021 #define _IS_TYPE5 0x04000000
00022 #define _IS_TYPE6 0x02000000
00023
00024
00025 typedef unsigned long serial_t;
00026
00027 class MsgData : public JObject
00028 {
00029 public:
00030 MC_SerializeHeader();
00031
00032 public:
00033 MsgData() : MC_SerializeConstructor( _IS_MSG_DATA, "MsgData;", "FRED", "1.0", NULL ) { }
00034
00035 virtual ~MsgData() {
00036 // delete[] abc;
00037 MC_SerializeDestructor()
00038 }
00039
00040 // char* abc;
00041 };
00042
00043
00044 class Derived : public MsgData {
00045 public:
00046 ULONG something;
00047 virtual ~Derived() { }
00048 };
00049
00050 class Derived2 : public MsgData {
00051 public:
00052 double anything;
00053 virtual ~Derived2() { }
00054 };
00055
00056 class Medium : public Derived, public Derived2 {
00057 public:
00058 virtual ~Medium() { }
00059 };
00060
00061 class Huge : protected Derived, private Derived2 {
00062 public:
00063 virtual ~Huge() { }
00064 };
00065 class Huge2 : private Derived, private Derived2 {
00066 public:
00067 virtual ~Huge2() { }
00068 };
00069
00070 class Type1 { };
00071 struct Type2 { };
00072
00073 void ReceiveMsg( void* p ) {
00074 size_t OFFSET = MC_getSerialOffset( MsgData );
00075 size_t OFFSET2 = MC_getSerialOffset( JObject );
00076
00077 serial_t s = MC_getSerial(p, OFFSET );
00078 serial_t s2 = MC_getSerial((JObject*)p, OFFSET2);
00079
00080 printf("[%d][%x]-", OFFSET, s );
00081 printf("[%d][%x]+", OFFSET2, s2);
00082 printf("[%x][ ] ", ((JObject*)p)->SerializationID );
00083
00084 if ( MC_testSerial(p, OFFSET, _IS_MSG_DATA) ) {
00085 printf("Type: MsgData* \n" );
00086 MC_printSerialInfo( ((MsgData*)p)-> )
00087 } else {
00088 printf("Type: INVALID \n" );
00089 }
00090 }
00091
00092
00093 void test()
00094 {
00095 MsgData* msg = new MsgData();
00096
00097 Derived* d = new Derived();
00098 Derived2* d2 = new Derived2();
00099 Medium* mm = new Medium();
00100 Huge* h = new Huge();
00101 Huge2* h2 = new Huge2();
00102
00103 ULONG val = MSG_DATA_SERIAL;
00104 ULONG val2 = 12345678UL;
00105
00106 Type1* t1 = new Type1();
00107 Type2* t2 = new Type2();
00108
00109 printf("\n*** Main Begin ***\n");
00110
00111 printf("\tMsgData \t");
00112 ReceiveMsg( msg );
00113
00114 printf("\tDerived \t");
00115 ReceiveMsg( d );
00116
00117 printf("\tDerived2\t");
00118 ReceiveMsg( d2 );
00119
00120 printf("\tMedium \t");
00121 ReceiveMsg( mm );
00122
00123 printf("\tHuge \t");
00124 ReceiveMsg( h );
00125
00126 printf("\tHuge2 \t");
00127 ReceiveMsg( h2 );
00128
00129 printf("\n\tULONG \t");
00130 ReceiveMsg( &val );
00131
00132 printf("\n\tULONG \t");
00133 ReceiveMsg( &val2 );
00134
00135 printf("\n\tType1 \t");
00136 ReceiveMsg( t1 );
00137
00138 printf("\n\tType2 \t");
00139 ReceiveMsg( t2 );
00140
00141 printf("\n\n*** End of Main ***\n");
00142
00143 delete d;
00144 delete d2;
00145 delete mm;
00146 delete h;
00147 delete h2;
00148 delete t1;
00149 delete t2;
00150
00151 // delete msg;
00152
00153 }
00154
00155
00156 int main() {
00157 test();
00158 return 0;
00159 }
00160
00161