README.md
1 # Service generator
2
3 The service generator auto-generates interface classes to invoke the service's
4 method running on a Nugget device. Three components can be generated:
5
6 1. Interface class declarations (header)
7 2. Interface class definitions (source)
8 3. Interface class mock declaration (mock)
9
10 ## Generated classes
11
12 All classes are generated in a namespace matching that of the protobuf package.
13 Each service generated its own header files, for example `service Example` is
14 included with:
15
16 #include <Example.client.h>
17 #include <MockExample.client.h>
18
19 ### Service interface
20
21 A pure virtual class is generated which declares the methods offered by the
22 service. This class is named after the service with and 'I' prepended, for
23 example `service Example` generates `class IExample`.
24
25 The methods return the `uint32_t` app status code and takes references to the
26 input and ouput messages as arguments. The app's response will be decoded into
27 the output message if the app does not return an error.
28
29 This interface class is the type that should be used the most as it allows mocks
30 to be injected for testing.
31
32 ### `libnos` implementation
33
34 An impementation of the service interface which wraps a `NuggetClient` reference
35 is also generated. This is the concrete implementation for invoking a method in
36 a service running on Nugget and exchanging messages with it. The name of this
37 class is the same as that of the service, for example `service Example` generates
38 `class Example`.
39
40 ### Mocks
41
42 The generator can further produce mocks of the service interface to simplify
43 testing of code that uses the service. This class's name is the name of the
44 service prepended with 'Mock', for example `service Example` generates
45 `class MockExample`.
46