2
votes

I have a problem with serializing classes generated by corba - especially with any kind of sequences - TAO::unbouded_value_sequence, TAO::unbouded_basic_string_sequence, etc.

Is there any "good" solution for serialization of CORBA structures or do I have reverse engineer the code of corba clases and try to write serialization funtion for each of them?

EDIT:

      struct Something;

      typedef
        TAO_Var_Var_T<
            Something
          >
        Something_var;

      typedef
        TAO_Out_T<
            Something
          >
        Something_out;


      struct  Something
      {
        typedef Something_var _var_type;
        typedef Something_out _out_type;

        static void _tao_any_destructor (void *);
        TAO::String_Manager member1;
      };
    class SequenceOfSomething;

  typedef
    TAO_VarSeq_Var_T<
        SequenceOfSomething
      >
    SequenceOfSomething_var;

  typedef
    TAO_Seq_Out_T<
        SequenceOfSomething
      >
    SequenceOfSomething_out;

  class  SequenceOfSomething
    : public
        TAO::unbounded_value_sequence<
            Something
          >
  {
  public:
    SequenceOfSomething (void);
    SequenceOfSomething ( ::CORBA::ULong max);
    SequenceOfSomething (
        ::CORBA::ULong max,
        ::CORBA::ULong length,
        SequenceOfSomething* buffer, 
        ::CORBA::Boolean release = false
      );
    SequenceOfSomething (const SequenceOfSomething &);
    virtual ~SequenceOfSomething (void);

    static void _tao_any_destructor (void *);

    typedef SequenceOfSomething_var _var_type;
    typedef SequenceOfSomething_out _out_type;


  };

This is some sample code generated from IDL definitions.

2
The good practice is to implement non-intrusive serialization for your types. What is the question? (HINT you might want to show some code)sehe
I would share some code if I could ;) Of course I do it in non-intrusive manner - I'm just asking for some resources or advices on how to implement serialize() for these "containers". CORBA structures also contain some members and typedefs that are added in process of compilation from IDL files. usually it looks like this: typedef SomeType_var _var_type; typedef SomeType_out _out_type; static void _tao_any_destructor (void *) I am not sure what to do about these things. I have no previous experience with CORBA.Siekacz
You're asking for docs/tutorials then. That's off topic. I have dozens of boost-serialization answers on SO. I wager half of them are examples of how to serialize user defined (template) types. Start there?sehe
Also, just post a sample IDL-generated header then perhaps. It's trivial to rename things if you think it's top-secretsehe
I added some example code.Siekacz

2 Answers

2
votes

I installed the ACE+TAO frameworks, and fiddled with things.¹

It looks like it's easier to go from the actual IDL.

The code to parse the IDL is included in the SDK, so maybe you can leverage that to generate some serialization code.

Sidenote: why Boost Serialize something that has IIOP serialization fully implemented for it? Could you consider Boost Serializing a binary buffer with the ACE serialization? If not, why not?


¹ actually compiling code: http://paste.ubuntu.com/12907686/

0
votes

Thanks to @sehe, this seems to be working:

namespace boost { namespace serialization {

    template <typename Archive, typename T>
        inline void save(Archive& ar, const TAO::unbounded_value_sequence<T>& varSequence, unsigned int /*version*/)
        {
            size_t length = varSequence.length();
            ar & length
               & boost::serialization::make_array(varSequence.get_buffer(), varSequence.length());
        }

    template <typename Archive, typename T>
        void load(Archive& ar, TAO::unbounded_value_sequence<T>& varSequence, unsigned int /*version*/)
        {
            size_t length;
            ar & length;

            varSequence.length(length);
            ar & boost::serialization::make_array(varSequence.get_buffer(), varSequence.length());
        }

    template <typename Archive, typename T>
        inline void serialize(Archive& ar, TAO::unbounded_value_sequence<T>& varSequence, const unsigned int version)
        {
            split_free(ar, varSequence, version); 
        }

    template <class Archive>
        inline void serialize(Archive& ar, SequenceOfSomething& seq, unsigned int version)
        {
            ar & base_object<TAO::unbounded_value_sequence<Something>>(seq);
        }
} }