Home

User`s Manual

image

Contents

1. 3 3 3 Thread per request strategy In this case the server will create a new thread for each new incoming request To use the Thread per request Strategy create the server providing it with a ThreadPerRequestStrategy object in the constructor method ThreadPerRequestStrategy perRequest NULL BankProtocol protocol NULL TCPerverTransport transport NULL BankServer server NULL BankServerImplExample servant try perRequest new ThreadPerRequestStrategy transport new TCPServerTransport 127 0 0 1 8080 protocol new BankProtocol server new BankServer perRequest transport protocol servant server gt serve catch eprosima rpc exception InitializeException amp ex std cout lt lt ex what lt lt std endl 23 4 HelloWorld example In this section a simple example is shown step by step This example only has one remote procedure A client can invoke this procedure by passing a string with a name as parameter The server returns a new string that appends the name to a greeting sentence 4 1 Writing the IDL file Write a simple interface named Helloworld that has a hello method Store this IDL definition in a file named Helloworld idl HelloWdorld idl interface HelloWorld dj string hello in string name 4 2 Generating specific code Open a command prompt and go to the directory containing Helloworld idt file If you are running t
2. server gt serve catch eprosima rpc exception InitializeException tex std cout lt lt ex what lt lt std endl 21 3 2 One way calls Sometimes a remote procedure doesn t need the reply from the server For these cases eProsima Fast RPC supports one way calls A developer can define a remote procedure as one way and when the client application calls the remote procedure the thread does not wait for any reply from the server To create a one way call the remote procedure has to be defined in the IDL file with the following rules e The oneway reserved word must be used before the method definition e The returned value of the method must be void e The method cannot have any inout Or out parameter An example of how a one way procedure has to be defined using IDL is shown below interface Bank 1 oneway void deposit in Account ac in long money 5 3 3 Threading Server strategies eProsima Fast RPC library offers several threading strategies that the server may use when a request arrives This subsection describes these strategies 3 3 1 Single thread strategy This is the simplest strategy in which the server only uses one thread for doing the request management In this case the server only executes one request at a given time The thread used by the server to handle the request is the reception thread To use Single Thread Strategy create the server providing th
3. The proxy provides a constructor It expects the network transport that will be used to establish the connection with the server as a parameter The second parameter is the protocol Again it is generated by fastrpcgen and its duty is to serialize and deserialize protocol data The proxy provides the remote procedures to the developer Using the suggested IDL our proxy will provide the remote procedure deposit 18 2 4 2 Exceptions While a remote procedure call is executed an error can occur In these cases exceptions are used to report errors Following exceptions can be thrown when a remote procedure is called Exception Description eprosima rpc exception Cli This exception is thrown when there is a problem in entInternalException the client side eprosima rpc exception This exception is thrown when the maximum time was verTimeoutException exceeded waiting the server s reply eprosima rpc exception This exception is thrown when there is a problem in verInternalException the server side eprosima rpc exception This exception is thrown when the proxy cannot find verNotFoundException any server All exceptions have the same base class eprosima rpc exception Exception 2 4 3 Example Using the suggested IDL the developer can access to deposit procedure the following way BankProtocol protocol NULL TCPProxyTransport transport NULL BankProxy proxy NULL try protocol new Ban
4. 15 2 2 1 FASTRPCGEN Command SyMtaX cccccnncncooonnnnnnnnnnanononnnnnnnnncnnnnnnnonnnnnnncnnanannnnnnnnnos 15 PPAT AE A E T TA 16 ALA CUENCIA a aa eaa E easa a aae eea Eaa 16 2 3 Server implementatiON oooooonnccncnnncooooonnnnnnnnonananononnnnnnnnnnnnononnnnnnnnnnnnonnnnnnnnnnnnnnnnnns 16 DSN PAP I CP RE O E EE E A E A E 17 2732 EXGE PLIONS A A E A A T 17 2323 EXAM AEEA E E T SE EE E E E 18 2 4 Clientimpleme ntatioNi siaa A AEE E ASS 18 A O 18 2 04 22 EXCOPUON Sissi a o da 19 2 AS EXAM ii A a A a Hane eed pes we 19 S Advanced oN E D S dido ibas 20 3L Network transport S serna a a eA betes 20 SV TEP Trans O tninn n A e a 20 SIPOO EEA VAO 1 EAEE AE E a AA 22 3 3 Threading Server strategieS ooooccccnnnoccccnnononnnonnnoncnnnnnnnnnnnnnonnnnnononnnnnnnnnnr nn nan nnnnnos 22 3 3 1 Single thread Strategy ccooooocconnnccnnnnooooonnnnnnnnnnnnonononnnnnonnnnnnnnnonnnnnnnnnnnnnnnonnnnnnos 22 3 3 2 Thread P ol Strateg Vii dle id 23 3 3 3 Thread per request strates ab 23 4 HelloWorld example ccccconooooocncnnncncnnnnonoonnnononononnnnnnnnnnnnnnncnnnnnnnonnnnnnnnnn nn non non nnnnainnns 24 Writing the Dl leia 24 42 Generating SPECIFIC cl iia necdasantitien dole sedeessattaleulasedncssaluoiecubdwlves 24 4 3 Client implementation dada 25 4 4 Server iMpleMentation cccccssscccceccessssssseeeecceecsseesssneeeseeeeesssssseeeseeeeeeeeeeeeeeess 25 4 5 Build ANG EXE CUT nia coresadansdeaueivendsunssaniveusondytnaaiions 26 1 Intro
5. following example exception Exception1 1 long count J exception Exception2 string msg 5 void exceptionFunction raises Exception1 Exception2 13 2 1 1 6 Interface definition The remote procedures that the server will offer have to be defined in an IDL interface An example of how an interface should be defined is shown interface InterfaceExample y Set of remote procedures The IDL interface will be mapped in three classes InterfaceExampleProxy A local server s proxy that offers the remote procedures to the client application Client application must create an object of this class and call the remote procedures InterfaceExampleServerImpl This class contains the remote procedures definitions These definitions must be implemented by the developer eProsima Fast RPC creates one object of this class It is used by the server InterfaceExampleServer The server implementation This class executes a server instance 2 1 1 7 Module definition To group related definitions such as complex types exceptions functions and interfaces a developer can use modules module ModuleExample a5 Set of definitions A module will be mapped into a C namespace and every definition inside it will be defined within the generated namespace in C 2 1 1 8 Limitations fastrpcgen application has some limitations concerning IDL syntax Two procedures cannot have the same nam
6. server Server public BankServer eprosima rpc strategy ServerStrategy amp strategy eprosima rpc transport ServerTransport amp transport eprosima rpc protocol BankProtocol protocol account_accountNumberResourceServerImpl amp servant virtual BankServer E The server provides a constructor with four parameters The strategy parameter expects a server s strategy that defines how the server has to manage incoming requests Server strategies are described in the section 3 3 Threading Server strategies The second parameter expects the network transport that will be used to establish connections with proxies The third parameter is the protocol It s generated by fastrpcgen and it s the class that deserializes received data and gives it to the user implementation Finally the fourth parameter is the server skeleton implemented by the user for example by filling the empty example given 2 3 2 Exceptions In the server side developers can inform about an error in the execution of the remote procedures The exception eprosima rpc exception ServerInternalException can be caught in the developer s code This exception will be delivered to the proxy and will be thrown in the proxy s side An example of how this exception can be thrown is shown below ReturnCode BankServerImp1 deposit in const Account amp ac in int32_t money ReturnCode returnedValue SYSTEM_ERROR throw epro
7. are the skeleton of the interfaces offered by the server All the remote procedures are defined in these files and the behavior of each one has to be implemented by the developer For the remote procedure deposit seen in our Example the possible generated definition is ReturnCode BankServerImp1 deposit in const Account amp ac in int32_t money ReturnCode returnedValue SYSTEM_ERROR return returnedValue Keep in mind a few things when this servant is implemented e in parameters can be used by the developer but their allocated memory cannot be freed either any of their members e inout parameters can be modified by the developer but before allocate memory in their members old allocated memory has to be freed e out parameters are not initialized The developer has to initialize them The code generated by fastrpcgen also contains the server classes These classes are implemented in the files lt IDLName gt Server h and lt IDLName gt Server cxx They offer the resources implemented by the servants When an object of the class lt IDLName gt Server is created proxies can establish a connection with it How this connection is created and how the proxies find the server depends on the selected network transport These transports are described in section 3 1 Network transports 16 2 3 1 API Using the suggested IDL example the API created for this class is class BankServer public eprosima rpc
8. 127 0 0 1 8080 ExampleProtocol protocol new ExampleProtocol ExampleProxy proxy new ExampleProxy transport protocol proxy gt exampleMethod or to implement a server using the generated skeleton TCPServerTransport transport new TCPServerTransport 127 0 0 1 8080 ExampleProtocol protocol new ExampleProtocol SingleThreadStrategy single new SingleThreadStrategy ExampleServerImpl servant ExampleServer server new ExampleServer single transport protocol servant server gt serve See section 4 HelloWorld example for a complete step by step example 1 3 Main Features Synchronous and one way invocations o The synchronous invocation is the most common one It blocks the clients thread until the reply is received from the server o The one way invocation is a fire and forget invocation where the client does not care about the result of the procedure It does not wait for any reply from the server Different threading strategies for the server These strategies define how the server acts when a new request is received The currently supported strategies are o Single thread strategy Uses only one thread for every incoming request o Thread pool strategy Uses a fixed amount of threads to process the incoming requests o Thread per request strategy Creates a new thread for processing each new incoming request High performance The framework uses a fast ser
9. ankProtocol transport new TCPProxyTransport 192 168 1 123 8080 proxy new BankProxy transport protocol catch eprosima rpc exception InitializeException amp ex std cout lt lt ex what lt lt std endl Account ac int32_t money ReturnCode depositRetValue try depositRetValue proxy gt deposit ac money catch eprosima rpc exception Exception amp ex 20 std cout lt lt ex what lt lt std endl TCPServerTransport TCPServerTransport class implements a TCP transport that should be used by servers class TCPServerTransport public ServerTransport public TCPServerTransport const std string amp to_connect virtual TCPServerTransport 5 The constructor receives a parameter representing the IP address and port that the server will use to read incoming requests Using the suggested IDL example the developer could create a server that will be listening in the network interface with address 192 168 1 123 and port 8080 unsigned int threadPoolSize 5 ThreadPoolStrategy pool NULL BankProtocol protocol NULL TCPServerTransport transport NULL BankServer server NULL BankServerImplExample servant try pool new ThreadPoolStrategy threadPoolSize tcptransport new TCPServerTransport 192 168 1 123 8080 protocol new BankProtocol server new BankServer pool transport protocol servant
10. arameters in the C function is the same as the order in the IDL file The parameters are mapped in C as it was described in section 2 1 1 3 Parameter definition Following these rules the previous example would generate the following C functions int32_t funcName int16_t param1 int32_t amp param2 12 2 1 1 5 Exception definition IDL functions can raise user defined exceptions to indicate the occurrence of an error An exception is a structure that may contain several fields An example of how to define an exception is shown below exception ExceptionExample long count string msg 3 This example would generate the following C exception class ExceptionExample public eprosima rpc exception UserException public ExceptionExample ExceptionExample const ExceptionExample amp ex ExceptionExample ExceptionExample amp amp ex ExceptionExample amp operator const ExceptionExample amp ex ExceptionExample amp operator ExceptionExample amp amp ex virtual ExceptionExample throw virtual void raise const Getters and Setters int32_t count const int32_t amp count void count int32_t _count private Exception members int32_t m_count std string m_msg y To specify that an operation can raise one or more user defined exceptions first define the exception and then add an IDL raises clause to the operation definition like the
11. duction eProsima Fast RPC is a high performance remote procedure call RPC framework It combines a software stack with a code generation engine to build efficient services for several platforms and programming languages eProsima Fast RPC uses a high performance serialization mechanism over a lightweight communication layer 1 1 Remote Procedure Calls RPC There are three main communication patterns used in distributed systems e Publish Subscribe e Request Reply e Point to Point One example of Request Reply pattern is the Remote Procedure Call RPC RPC allows an application to call a subroutine or procedure in another address space commonly in another computer on a shared network eProsima Fast RPC provides an implementation of this general concept enabling developers to build distributed applications with minimal effort The framework generates the Request Reply code from the procedure definition using an Interface Definition Language IDL allowing the developer to focus in the application logic without bothering about the networking details Client ea i Server Proxy Skeleton RPC Reply 1 2 A quick example You write an IDL file like this interface Example 3 void exampleMethod Then you process the file with the fastrpcgen compiler to generate C code Afterwards you use that code to invoke remote procedures with the client proxy TCPProxyTransport transport new TCPProxyTransport
12. e Complex types arrays and sequences used in procedure definitions must be previously named using typedef keyword as CORBA IDL 2 0 specification enforces 14 2 1 2 Example This example will be used as a base to other examples in the following sections It shows the IDL syntax described in the previous subsection file Bank idl enum ReturnCode E SYSTEM_ERROR ACCOUNT_NOT_FOUND AUTHORIZATION_ERROR NOT_MONEY_ENOUGH OPERATION_SUCCESS struct Account string AccountNumber string Username string Password 3 interface Bank y ReturnCode deposit in Account ac in long money 2 2 Generating specific remote procedure call support code Once the API is defined in a IDL file we need to generate code for a client proxy and a server skeleton eProsima Fast RPC provides the fastrpcgen tool for this purpose it parses the IDL file and generates the corresponding supporting code 2 2 1 FASTRPCGEN Command Syntax The general syntax is fastrpcgen options lt IDL file gt lt IDL file gt Options Description help Shows help information version Shows the current version of eProsima Fast RPC ppPath lt directory gt Location of the C C preprocessor ppDisable Disables the C C preprocessor Useful when macros or includes are not used replace Replaces existing generated files example lt platform gt Creates a solution for a specific platform This solution wi
13. e constructor with a SingleThreadStrategy Object SingleThreadStrategy single NULL BankProtocol protocol NULL TPCServerTransport transport NULL BankServer server NULL BankServerImplExample servant try single new SingleThreadStrategy transport new TCPServerTransport 127 0 0 1 8080 protocol new BankProtocol server new BankServer single transport protocol servant server gt serve catch eprosima rpc exception InitializeException amp ex std cout lt lt ex what lt lt std endl 22 3 3 2 Thread Pool strategy In this case the server manages a thread pool that will be used to process the incoming requests Every time a request arrives the server assigns it to a free thread located in the thread pool To use the Thread Pool Strategy create the server providing the constructor with a ThreadPoolStrategy Object unsigned int threadPoolSize 5 ThreadPoolStrategy pool NULL BankProtocol protocol NULL TCPServerTransport transport NULL BankServer server NULL BankServerImplExample servant try pool new ThreadPoolStrategy threadPoolSize transport new TCPServerTransport 127 0 0 1 8080 protocol new BankProtocol server new BankServer pool transport protocol servant server gt serve catch eprosima rpc exception InitializeException amp ex std cout lt lt ex what lt lt std endl
14. eProsima Fast RPC User Manual Version 0 3 3 The Middleware Experts eProsima O 2014 eProsima Proyectos y Sistemas de Mantenimiento SL amp Ronda del poniente 16 Bajo K Y e FO S f a 28760 Tres Cantos Madrid Tel 34 91 804 34 48 info eProsima com www eProsima com Trademarks eProsima is a trademark of Proyectos y Sistemas de Mantenimiento SL All other trademarks used in this document are the property of their respective owners License eProsima Fast RPC is licensed under the terms described in the FASTRPC_LICENSE file included in this distribution Technical Support e Phone 34 91 804 34 48 e Email support eProsima com Table of Contents o A ees vancacincc a salle ea paula ac a a aaaea EEA aaa s Bua ea ine Chaba ia era a aia 4 1 1 Remote Procedure Calls RPC ccccccccccccscssssssscesssececesesssceeesseceesseeseeeeueeeeeeeeeeeueds 4 1 2 A QUICk example A a la ad ea heeded Seek 5 1 3 Main Features iiss acest scecceds ai eia aeea a Save rans SARA NEEE ENEO rE A 6 2 Building an applicatio Moeras nenie eeri e E EE E E E NEEE Ea a Ra 7 2 1 Defining a set of remote procedureS cococoocccnnnncnnnnonooonnnnnnoncnnnnnnnnnnnnnnnonnnnnnnnnnnnnononos 8 2 1 1 IDL Syntax and mapping to CAk oooooccccncccnnnoooonnnnnnnnnnnnnnannnnnnnnnncnnnnnonononononnnenenanos 9 DIT DEXA E A E E A E E vaadeeustesdedeseee choles 15 2 2 Generating specific remote procedure call support COde cccccccncnncnnnnnnnnnnnnnno
15. er unsigned unsigned long long uint64_t ullong_member long long ullong_member float float float_member float float_member double double double_member double double_member boolean boolean boolean_member bool boolean_member string lt 20 gt string_member std string string_member maximum Length 20 unbounded string string_member std string string_member string maximum Length 255 2 1 1 2 Complex types Complex types can be created combining simple types These complex types can be used as parameters or returned values The following table shows the supported complex types how they are defined in the IDL file and what fastrpcgen generates in C 11 language IDL Type struct typedef enum PrimitiveEnum ENUM1 ENUM2 ENUM3 y enum PrimitiveEnum ENUM1 10 ENUM2 20 30 struct PrimitiveStruct char char_member E union PrimitiveUnion switch long case 1 short short_member default long long_member typedef short TypedefShort TABLE 2 SPECIFYING COMPLEX TYPES IN IDL FOR C USING C 11 NATIVE TYPES Sample in IDL File Sample Output Generated by fastrpcgen enum PrimitiveEnum ENUM1 ENUM2 ENUM3 uint32_t 3 enum PrimitiveEnum ENUM1 10 ENUM2 20 30 uint32_t class PrimitiveStruct public Constructors PrimitiveStruct Getter and Setters char char_member void char_member char x private char m_char_membe
16. hello_ret Create the greeting sentence hello_ret Hello name return hello_ret 4 5 Build and execute To build your code using Visual Studio 2010 make sure you are in the Debug or Release profile and then build it F7 Now go to lt example_dir gt bin x64Win64VS2010 directory and execute HelloWorldServerExample exe You will get the message INFO lt eprosima rpc server Server server gt Server is running Then launch HelloWorldClientExample exe You will see the result of the remote procedure call Hello Richard This example was created statically To create a set of DLLs containing the protocol and the structures select the Debug DLL or Release DLL profile and build it F7 Now to get your DLL and LIB files go to lt example_dir gt objs x64Win64vS2010 directory You can now run the same application dynamically using the exe files generated in lt example_dir gt bin x64Win64vS2010 but first you have to make sure your dll location directory is appended to the PATH environment variable To build your code in Linux use this command make f makefile _x64Linux2 6gcc4 4 5 No go to lt example_dir gt bin x64Linux2 6gcc4 4 5 directory and execute the binaries as it has been described for Windows 26
17. his example in Windows type in and execute the following line fastrpcgen example x64Win64VS52010 HelloWorld idl If you are running it in Linux execute this one fastrpcgen example x64Linux2 6gcc4 4 5 HelloWorld idl Note that if you are running this example in a 32 bit operating system you have to use example i86Win32VS2010 or example i86Linux2 6gcc4 4 5 instead This command generates the client stub and the server skeletons as well as some project files designed to build your HelloWorld example In Windows a Visual Studio 2010 solution will be generated named rpcsolution lt target gt sin being lt target gt the chosen example platform This solution is composed by five projects HelloWorld with the common classes of the client and the server like the defined types and the specific communication protocol HelloWorldServer with the server code HelloWorldClient with the client code HelloWorldServerExample with a usage example of the server and the implementation skeleton of the RPCs HelloWorldClientExample with a usage example of the client In Linux on the other hand it generates a makefile with all the required information to compile the solution 24 4 3 Client implementation Edit the file named HelloWorldClientExample cxx In this file the code for invoking the hello RPC using the generated proxy is generated You have to add two more statements one to set a value to the rem
18. ialization mechanism that increases the performance 2 Building an application eProsima Fast RPC allows the developer to easily implement a distributed application using remote procedure invocations In client server paradigm a server offers a set of remote procedures that the client can remotely call How the client calls these procedures should be transparent The proxy object represents the remote server and this object offers the remote procedures implemented by the server In the same way how the server obtains a request from the network and how it sends the reply should also be transparent The developer just writes the behavior of the remote procedures using the generated skeleton Steps to build an application Define a set of remote procedures using the Interface Definition Language Using the provided IDL compiler generate the specific remote procedure call support code a Client Proxy and a Server Skeleton Implement the server filling the server skeleton with the behavior of the procedures Implement the client using the client proxy to invoke the remote procedures This section will describe the basic concepts of these four steps that a developer has to follow to implement a distributed application The advanced concepts are described in section 3 Advanced concepts 2 1 Defining a set of remote procedures An Interface Definition Language IDL is used to define the remote procedures the server will offer Data T
19. kProtocol transport new TPCProxyTransport 127 0 0 1 8080 proxy new BankProxy transport protocol catch eprosima rpc exception InitializeException amp ex std cout lt lt ex what lt lt std endl Account ac int32_t money ReturnCode depositRetValue try depositRetValue proxy gt deposit ac money catch eprosima rpc exception Exception amp ex std cout lt lt ex what lt lt std endl 19 3 Advanced concepts 3 1 Network transports eProsima Fast RPC provides one network transport a TCP transport 3 1 1 TCP Transport The purpose of this transport is to create a connection between a proxy and a server that will communicate through TCP This transport is implemented by two classes One is used by proxies and the other is used by servers TCPProxyTransport TCPProxyTransport class implements a TCP transport that should be used by proxies class TCPProxyTransport public ProxyTransport public TCPProxyTransport const std string amp serverAddress virtual TCPProxyTransport E The constructor has a parameter that receives the server URL to connect to Using the suggested IDL example the developer could create a proxy to connect with a server located in the public IP address 192 168 1 123 and port 8080 BankProtocol protocol NULL TCPProxyTransport transport NULL BankProxy proxy NULL try protocol new B
20. ll be used by the developer to compile both client and server Possible values i86Win32VS2010 x64Wwin64VS2010 i86Linux2 6gcc4 4 5 x64Linux2 6gcc4 4 5 d lt path gt Sets an output directory for generated files t lt temp dir gt Sets a specific directory as a temporary directory 15 The fastrpcgen application generates several files that will be described in this section Their names are generated using the IDL file name The lt IDLName gt tag has to be substituted by the file name 2 2 2 Server side fastrpcgen generates C header and source files with the declarations and the definitions of the remote procedures These files are the skeletons of the servants that implement the defined interfaces The developer can use each definition in the source files to implement the behavior of the remote procedures These files are lt IDLName gt ServerImpl h and lt IDLName gt ServerImpl cxx fastrpcgen also generates a C source file with an example of a server application and a server instance This file is lt IDLName gt ServerExample cxx 2 2 3 Client side fastrpcgen generates a C source file with an example of a client application and how this client application can call a remote procedure from the server This file is lt IDLName gt ClientExample cxx 2 3 Server implementation After the execution of fastrpcgen two files named lt IDLName gt ServerImpl cxx and lt IDLName gt ServerImpt h will be generated These files
21. ote procedure parameter and another to print the returned value This is shown in the following example int main int argc char argv HelloWorldProtocol protocol NULL TCPProxyTransport transport NULL HelloWorldProxy proxy NULL Creation of the proxy for interface HelloWorld try protocol new HelloWorldProtocol transport new TCPProxyTransport 127 0 0 1 8080 proxy new HelloWorldProxy transport protocol catch InitializeException amp ex std cout lt lt ex what lt lt std endl return 1 Create and initialize parameters std string name Richard Create and initialize return value std string hello_ret Call to remote procedure hello try hello_ret proxy gt hello name catch SystemException amp ex std cout lt lt ex what lt lt std endl std cout lt lt hello_ret lt lt std endl delete proxy delete transport delete protocol return 0 4 4 Server implementation fastrpcgen creates the server skeleton in the file HelloWorldServerImplExample cxx The remote procedure is defined in this file and it has to be implemented In this example the procedure returns a new string appending with a greeting sentence Open the file and copy this code for implementing that behavior 25 include HelloWorldServerImpl1 h std string HelloWorldServerImpl hello in const std string amp name std string
22. r class PrimitiveUnion public 7 Constructors PrimitiveStruct Discriminator int32_t _d void _d int32_t x Getter and Setters int16_t short_member int32_t long _member private int32_t m_d int16_t m_short_member int32_t m_long_ member typedef int16_t TypedefShort 10 array struct OneDArrayStruct class OneDArrayStruct See note short short_array 2 below J private std array lt int16_t 2 gt m_short_array Js struct TwoDArrayStruct class TwoDArrayStruct short short_array 1 2 y private std array lt std array lt int16_t 1 gt m_short_array bounded struct SequenceStruct class SequenceStruct sequence sequence lt short 4 gt See note short_sequence below P private std vector lt int16_t gt m_short_sequence unbounded struct SequenceStruct class SequenceStruct sequence sequence lt short gt See note short_sequence below F private std vector lt int16_t gt m_short_sequence Es Note These complex types cannot be used directly as procedure s parameters In these cases use a typedef to redefine them 11 2 1 1 3 Parameter definition There are three reserved words used in the procedure s parameter definitions It is mandatory to use one of them in each procedure s parameter definition The following table shows these reserved words and their meanings Reserved word Meaning in The parameter i
23. s an input parameter inout The parameter acts as an input and output parameter output The parameter is an output parameter Suppose the type T is defined as the type of the parameter If the parameter uses the reserved word in and the type Tis a simple type or an enumeration then the type is mapped in C as T In the case the type Tis a complex type the type is mapped in C as const T amp If the parameter uses the reserved word inout or out then the type is mapped in C as T amp As it was commented in section 2 1 1 2 Complex types array and sequence types cannot be directly defined as parameter types To do so they have to be previously redefined using a typedef This redefinition can be used as a parameter 2 1 1 4 Function definition A procedure s definition is composed of two or more elements e The type of the returned value void type is allowed e The name of the procedure e Alist of parameters This list could be empty An example of how a procedure should be defined is shown below long funcName in short param1 inout long param2 fastrpcgen application maps the functions following these rules e The type of the C returned value is the same as the one defined in the IDL file using the tables described in sections 2 1 1 1 Simple types and 2 1 1 2 Complex types for the mapping e The name of the C function is the same as the name of the defined function in the IDL file e The order of the p
24. sima rpc exception ServerInternalException Error in deposit procedure return returnedValue 17 2 3 3 Example Using the suggested IDL Example the developer can create a server in the following way unsigned int threadPoolSize 5 ThreadPoolStrategy pool NULL BankProtocol protocol NULL TCPServerTransport transport NULL BankServer server NULL BankServerImplExample servant try pool new ThreadPoolStrategy threadPoolSize transport new TCPServerTransport 127 0 0 1 8080 protocol new BankProtocol server new BankServer pool transport protocol servant server gt serve catch eprosima rpc exception InitializeException tex std cout lt lt ex what lt lt std endl 2 4 Client implementation The code generated by fastrpcgen contains classes that act like proxies of the remote servers These classes are implemented in the files lt IDLName gt Proxy h and lt IDLName gt Proxy cxx The proxies offer the server resources and the developer can directly invoke its remote procedure 2 4 1 API Using the suggested IDL example the API of this class is class BankProxy public eprosima rpc proxy Proxy public BankProxy eprosima rpc transport ProxyTransport amp transport eprosima rpc protocol BankProtocol amp protocol virtual BankProxy ReturnCode deposit in const Account amp ac in int32_t money E
25. ypes used as parameter types in these remote procedures are also defined in the IDL file The IDL structure is based in OMG IDL and it is described in the following schema eProsima Fast RPC includes a Java application named fastrpcgen This application parses the IDL file and generates C code for the defined set of remote procedures fastrpcgen application will be described in the section 2 2 Generating specific remote procedure call support code 2 1 1 IDL Syntax and mapping to C User types defined through the IDL file are mapped to C 11 native types In this section this mapping is shown 2 1 1 1 Simple types eProsima Fast RPC supports a variety of simple types that the developer can use as parameters returned values and members of complex types The following table shows the supported simple types how they are defined in the IDL file and what the fastrpcgen generates in C 11 language TABLE 1 SPECIFYING SIMPLE TYPES IN IDL FOR C USING C 11 NATIVE TYPES IDL Type Sample in IDL File Sample Output Generated by fastrpcgen char char char_member char char_member wchar wchar wchar_member wchar_t wchar_member octet octet octet_member uint8_t octet_member short short short_member int16_t short_member unsigned unsigned short ushort_member uint16_t ushort_member short long long long_member int32_t long_member unsigned unsigned long ulong_member uint32_t ulong_member long long long long long llong member int64 t llong_memb

Download Pdf Manuals

image

Related Search

Related Contents

Think Outside Universal Bluetooth Keyboard Personal Computer User Manual  3206 - Candide  Makita 6906 User's Manual  PERICOLO  ELCODIS.COM - ELECTRONIC COMPONENTS DISTRIBUTOR  Instruções complementares  Guía del Usuario  MARITIME LIFE SUPPORT - Danish Maritime Authority  

Copyright © All rights reserved.
Failed to retrieve file