Version 4 (modified by nenko, 16 years ago) (diff) |
---|
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.
Related
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
- 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 respones on the base of the command
- the C++ program returns the reposne through its standard output
- the Java program receives the respone and acts on the base of it
This means that the Java program will be blocked until it recieves mething 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 wrapers 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:
Class diagram for Java part:
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.)