wiki:GROUP_WRAPPERS_R0

Version 5 (modified by izomorphius, 16 years ago) (diff)

--

Error: Macro BackLinksMenu(None) failed
compressed data is corrupt

Error: Macro TicketQuery(summary=GROUP_WRAPPERS_R0, format=table, col=summary|owner|status|type|component|priority|effort|importance, rows=description|analysis_owners|analysis_reviewers|analysis_score|design_owners|design_reviewers|design_score|implementation_owners|implementation_reviewers|implementation_score|test_owners|test_reviewers|test_score|) failed
current transaction is aborted, commands ignored until end of transaction block

Analysis

Will write native wrappers of portable libraries that can be used in Sophie2 for exotic purposes (media, embedded browser, flash player, etc.). By native wrappers I mean C++ programs that will read commands (sequences of integers) from their standard input and send responses (sequences of integers) to their standard output. These C++ programs should be built for every platform we support and will be invoked with Java code. These C++ wrappers will share code - common commands and responses and a simple program that handles them. This common code should be written once and reused, not copy-pasted in every specific wrapper.

Overview

In the first revision common commands/responses and simple program that uses them should be written.

Task requirements

  • Write commands that are common for all C++ wrappers
  • Write a makefile for building them (should be portable)
  • Write a simple program that handles commands and respones

Task result

Task result should be source code, makefile

Implementation idea

Make a hierarchy or commands and responses. Also the C++ program that handles them should in separate class in order to reuse it.

How to demo

Write Java demo that sends commands to the C++ wrapper and log the communication

Design

The communication between the C++ program and the Java program (Sophie2, except the demos) will be sequence of integers. We chose integers over string because there are too many encodings for strings. Every integer sequence will be in the following format:
<size> <id> ...
<size> and <id> are mandatory and their meanings are :

  • size - the length of the integer sequence. The size includes the size number itself.
  • id - command/sequence id

Example(start command, whose id is 0) : 2 0

The communication will be in the following way:

  • the Java program sends a command through the standard input of the C++ process
  • the C++ program creates a response on the base of the command
  • the C++ program returns the response through its standard output
  • the Java program receives the response and acts on the base of it

This means that the Java program will be blocked until it receive something from the standard input of the process so the Java wrapper will be in separate thread. Also the control of the C++ application will be in the Java part - it will run and stop it.

The flow of communication written above is common for all other wrappers and native applications. This code will reside in classes called Bridges.
There will be some common commands and responses:

  • StartCommand
  • StopCommand
  • OkResponse
  • ErrorResponse

Class diagram for C++ part:

source:/branches/private/nenko/experimental/sophie2-platform/doc/uml-design-diagrams/natives/javaMessagesCpp.png

Class diagram for Java part:

source:/branches/private/nenko/experimental/sophie2-platform/doc/uml-design-diagrams/natives/javaNativeWrapper.png

Implementation

(Describe and link the implementation results here (from the wiki or the repository).)

Testing

(Place the testing results here.)

Comments

(Write comments for this or later revisions here.)