Search code examples
c++design-patternsmemory-addresscommand-patternaddress-space

Address space independent representation of objects


If the receiver of a request can be represented in an address space-independent way, then you can transfer a command object for the request to a different process and fulfill the request there.

from : http://www.worldcat.org/isbn/9780201633610

How can an object be represented in address space independent way in c++?

edit : How can an object be represented in address space independent way in c++ so as to enable transfer of command objects to different process and be able to fulfil the request?


Solution

  • The paragraph you quoted is from the Command pattern, I think.

    A description of the pattern can also be found on the web at various sites. E.g. https://en.wikipedia.org/wiki/Command_pattern.

    The most common manifestations of the Command pattern in which the data corresponding to a command are transferred in address space independent way are:

    1. HTTP/FTP requests over the web.
    2. CORBA calls over the net.
    3. COM calls in MS Windows.

    I am sure there are plenty more technologies which allow you to execute a command in a remote machine or in a different process. They can work only because a command can be represented in an address space independent way and transmitted across the net or across process boundaries.

    How can an object be represented in address space independent way in c++?

    If the sender and receiver of the command can agree on a representation of data for basic types such as char, int, long, float, double, they can usually use them as building blocks to enable sending and receiving of higher level objects.