RemoteViz 10.6 : Major API changes

In order to provide your application with safer lifetime control on objects shared by RemoteViz, the API of RemoteViz will be updated in Open Inventor 10.6. The following document describes all the changes that we will introduce and will help you to port your application using this new API.

In addition to the API changes related to the usage of shared pointer, following API changes will be made


Class ServiceSettings(C++|Java|.Net)

Before 10.6, for a newly created ServiceSettings(C++|Java|.Net) object, the default value of the IP attribute was “auto”. Starting with version 10.6, the value “auto” has been removed and the default IP value is now “127.0.0.1”. See the setIP() and getIP() methods.


C++

Pointers

All arguments and return types using a pointer type are replaced by the equivalent shared pointer type. In other words, “Type* arg” will become “std::shared_ptr<Type> arg”. The shared_ptr type allows more than one owner to manage the lifetime of an object in memory. This is important if the application needs to hold a pointer to a RemoteViz object, for example, a RenderArea. Previously when RemoteViz was finished using an object, it would explicitly delete the object, making the pointer held by the application invalid. Now when RemoteViz is finished using an object, it calls the shared_ptr’s reset() method. If there is no other shared_ptr referencing the object, the object is deleted. But if the application is holding a shared_ptr, that pointer and the object remain valid (until the application resets its shared_ptr).

This API change will break source compatibility and generate errors with existing code. To fix these errors, replace pointers with shared pointers in your source code. To give you an idea of how this will change your code, consider the basic HelloCone example program (examples/source/RemoteViz/HelloCone).

Service main
OIV 10.5
    // Instantiate a service settings class
    ServiceSettings settings;
    . . .
    // Open the service by using the settings
    if (Service::instance()->open(&settings))

OIV 10.6
    // Instantiate a service settings class
    auto settings = std::make_shared<ServiceSettings>();
    . . .
    // Open the service by using the settings
    if (Service::instance()->open(settings))


ServiceListener.h
OIV 10.5
    virtual void onInstantiatedRenderArea(RemoteViz::Rendering::RenderArea *renderArea);

OIV 10.6
    virtual void onInstantiatedRenderArea(std::shared_ptr<RemoteViz::Rendering::RenderArea> renderArea) override;


ServiceListener.cxx
OIV 10.5
    void MyServiceListener::onInstantiatedRenderArea(RemoteViz::Rendering::RenderArea *renderArea)
    {
        // Instantiate a renderAreaListener class to manage the renderArea events (default behaviors).
        std::shared_ptr renderAreaListener(new RemoteViz::Rendering::RenderAreaListener());
        . . .
    }

OIV 10.6
    void MyServiceListener::onInstantiatedRenderArea(std::shared_ptr<RemoteViz::Rendering::RenderArea> renderArea)
    {
        // Instantiate a renderAreaListener class to manage the renderArea events (default behaviors).
        auto renderAreaListener = std::make_shared<RemoteViz::Rendering::RenderAreaListener>();
        . . .
    }

Derived Classes

We strongly recommend using the C++11 keyword “override” in all classes derived from the RemoteViz classes ServiceListener and RenderAreaListener so that the compiler checks that the virtual methods successfully override the corresponding virtual method in the base class.

Class Connection(C++)

  • bool sendMessage (const unsigned char* buffer, size_t size) const;
    is replaced by
    bool sendMessage(const std::vector<const unsigned char>& buffer) const;
  • New function bool isOpen() const; has been added to gets the state of a Connection (open or closed)

Class Client(C++)

  • bool sendMessage(const std::string& message, Connection** excludedConnections = nullptr, unsigned int num = 0) const;
    is replaced by
    bool sendMessage(const std::string& message, std::vector<std::shared_ptr<Connection>> excludedConnections = {}) const;
  • bool sendMessage (const unsigned char *buffer, size_t size, Connection **excludedConnections=nullptr, unsigned int num=0) const;
    is replaced by
    bool sendMessage(const std::vector<const unsigned char>& buffer, std::vector<std::shared_ptr<Connection>> excludedConnections = {}) const;
  • New function bool isConnected() const; has been added to get the state of the Client (connected or disconnected)

Class RenderArea(C++)

  • bool sendMessage(const std::string& message, Connection** excludedConnections = nullptr, unsigned int num = 0) const;
    is replaced by
    bool sendMessage(const std::string& message, std::vector<std::shared_ptr<Connection>> excludedConnections = {}) const;
  • bool sendMessage (const unsigned char *buffer, size_t size, Connection **excludedConnections=nullptr, unsigned int num=0) const;
    is replaced by
    bool sendMessage(const std::vector<const unsigned char>& buffer, std::vector<std::shared_ptr<Connection>> excludedConnections = {}) const;
  • New function bool isDisposed() const; has been added to get the state of the RenderArea (alive or disposed)

Java

Class Connection(Java)

  • SendMessage(byte[] buffer)
    is replaced by
    SendMessage(Collection<Byte> buffer)
  • New function boolean isOpen() has been added to get the state of a Connection (open or closed)

Class Client(Java) and Class RenderArea(Java)

  • SendMessage(byte[] buffer)
    is replaced by
    SendMessage(Collection<Byte> buffer)
  • SendMessage(byte[] buffer, Connection[] excludedConnections)
    is replaced by
    SendMessage(Collection<byte> buffer, Collection<Connection> excludedConnections)
  • SendMessage(string message, Connection[] excludedConnections)
    is replaced by
    SendMessage(string message, Collection<Connection> excludedConnections)
  • New function boolean isConnected() has been added in class Client(Java) to get the state of the Client (connected or disconnected)
  • New function bool isDisposed() has been added to Class RenderArea(Java) to get the state of a RenderArea (alive or disposed)

Class ServiceListener(Java)

  • OnReceivedMessage(RenderArea, Connection, byte[])
    is replaced by
    OnReceveivedMessage(RenderArea renderArea, Connection sender, Collection<Byte> buffer)

.Net

Class Connection(.Net)

  • SendMessage(byte[] buffer)
    is replaced by
    SendMessage(IList<byte> buffer)
  • New property IsOpen has been added to get the state of a Connection (open or closed)

Class Client(.Net) and Class RenderArea(.Net)

  • SendMessage(byte[] buffer)
    is replaced by
    SendMessage(IList<byte> buffer)
  • SendMessage(byte[] buffer, Connection[] excludedConnections)
    is replaced by
    SendMessage(IList buffer<byte>, IList<Connection> excludedConnections)
  • SendMessage(string message, Connection[] excludedConnections)
    is replaced by
    SendMessage(string message, IList<Connection> excludedConnections)
  • New property IsConnected has been added in Client(.Net) class to get the state of the Client (connected or disconnected)
  • New property IsDisposed has been added to Class RenderArea(.Net) to get the state of a RenderArea (alive or disposed)

Class ServiceListener(.Net)

  • OnReceivedMessage(RenderArea, Connection, Byte[])
    is replaced by
    OnReceveivedMessage(RenderArea renderArea, Connection sender, IList<byte> buffer)

 

0