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