Uploaded image for project: 'Ignite'
  1. Ignite
  2. IGNITE-3584

CPP: Refactor BinaryType class template.

    XMLWordPrintableJSON

Details

    • Task
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 1.6
    • 2.0
    • platforms

    Description

      1. All methods should be 'static'.
      2. Methods GetTypeName(), Read() and GetNull() should pass result to caller by reference argument and not by return value to avoid copying and temporary objects creation.
      3. For the BinaryType<T*>: additionally to the mentioned above, remove field typ and add type alias for the non-pointer type instead.

      Explanation:
      Current role of the BinaryType<T> in C++ is to provide Ignite with the information about its template type, to be used during serialization and deserialization. Unlike Java version, C++ BinaryType also used for user to provide implementation of Read and Write methods, i.e. methods that used to serialize and deserialize objects.

      We can not have non-template interface for this class as Write and Read methods have templated type in theirs signatures:

      void Write(BinaryWriter& writer, const T& obj); 
      T Read(BinaryReader& reader);
      

      We can not change template type T with non-template type as we don't have single root class in C++ like Object class in Java and we also don't have any type information at runtime.

      Thus we always need to know template type for the BinaryType<T> when we are instantiating it, thus we can not have any fabrics or any polymorphism for this class in C++ and internally we always use default constructor to get new instance of such a class.

      So, currently I can not see how having non static methods could be useful for this class.

      Attachments

        Issue Links

          Activity

            People

              isapego Igor Sapego
              isapego Igor Sapego
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: