Wednesday, April 10, 2013

serialization

Basically, serialization is bundling an object into something that can be moved to other machine. After moved to a machine, that thing is extracted into another object which is called deserialization. Overall, this assignment is easy. The hardest part is arranging the data structure so it is optimized. I use __m64 to try to optimize the data structure.

This class is the most challenging:

class Fish
{
   Apple pApple;
   Orange *pOrange;
 
   union
   {
      // this variable can share the memory address with the int and float. It has 8 bytes
      __m64 op1;
      struct
      {
         // these variables will be shared with op1
         int x;
         float y;
      };
   };


   union
   {
    // this integer variable also shared with chars variable
   int op2;
   
   struct
   {
      char a;
      char pad1,pad2,pad3;
   };
   };
};

I was thinking to make copying process in one stamp. But I can't figure out how to do it. This is the best I can do.

No comments:

Post a Comment