[[BackLinksMenu]] [[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|)]] = 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: [[BR]] ... [[BR]] and 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 and every wrapper ot native application should extends the corresponding Bridge[[BR]] There will be some common commands and responses: * StartCommand * StopCommand * OkResponse * ErrorResponse A new module will be created - org.sophie2.native. This module will contain the Java part, all commands and responses. In later revision they will be separated. Also there will be a distrib folder in this module where all native application builds will reside. By all I mean that every native application should be build on every platform we support - Windows 32/64 bit, Linux (whatever this means) 32/64 bit, Mac OS 32/64 bit (is there such separation in the Apple world?). Later these executable files can be copied under resources/distrib for the release. The C++ code will be in the same module in a folder named "native" in the same level as the src directory. There will be utility classes that will handle some common problems like: * encoding/decoding String to int representations * swapping BigEndian ints and LittleEndian ints * convert byte array to int array * functionality that is needed in the implementation section Class diagram for C++ part: [[Image(source:/trunk/sophie2-platform/doc/uml-design-diagrams/natives/javaMessagesCpp.png)]] Class diagram for Java part: [[Image(source:/trunk/sophie2-platform/doc/uml-design-diagrams/natives/javaNativeWrapper.png)]] Changeset: [5697] [5702] = Implementation = In order to start the demo: * Compile the native application you need (use make) * go to sophie2-platform/modules/org.sophie2.base.natlib/native * compile java_messages_demo.cpp * there's a makefile for convenience * Run JavaMessagesDemo with an argument - path to the compiled program In order to use this library: * Compile the native application you need (use make) * Create Command and Response extenders that suite your needs * For the native application extend JavaBridge and override createCommand so it creates the command you need * The the Java wrapper extend NativeBridge and override getExecutableString in order to tell the NativeBridge which process to start Changeset: * [5697] * [5702] - class diagrams * [5743] * [5759] - the module is renamed to org.sophie2.wrappers * [5760] - the module is renamed in sophie2-platform/pom.xml * [5761] - the renamed module's pom is changed * [5768] * [5769] - more renaming - the module is renamed to org.sophi2.base.natlib * [5770] * [5771] * [5772] * [5773] - updated class diagrams Implementation merged to the trunk in [5779]. = Testing = ^(Place the testing results here.)^ = Comments = ^(Write comments for this or later revisions here.)