Programmers will appreciate they
don't have to learn any special
language or file format to produce coid services/devices. Only a few
decorations (these are defined as empty C defines) in your header file
are required. This tool generates whole communication layer for
client and server from information found in that header. It does not
write to it.
Usage is
simple: coidgen [-f]
[-m] [-n] [-M] [-N] my_service.h [file.dev]
Options:
-f
- force coidgen to generate
all required files even if service header is older than these files.
-m - do not increment major
version (even if it should be incremented)
-n - do not increment minor
version (even if it should be incremented)
-M - increment major version
-N - increment minor version
By default, version of the service is extracted from
dispatch file,
methods in service header are compared against methods stored in
dispatch and
version is increased. You may want to compare your header file with an
older release and make another release that might have only minor
version changed (against your older release). In this case, use your
device.dev as the last argument.
Every
.dev file stores information about its methods, so coidgen
can extract version information from it, compare methods and increase
major or minor version accordingly.
For example: your last
release
version
is 2.3.20 (major.minor.build). Then you work on it and get version
7.1.40. If you then tell coidgen to use your old .dev file, it changes
version 2.3.20 according to difference between methods to one of these:
3.0.41
(major changes detected), 2.4.41 (minor changes detected) or 2.3.41 (no
changes detected).
All these version or methods information stored in dispatch file are in
a hexadecimal form and any change to it can crash coidgen :) So if you
change it you do it on your own risk.
Output of coidgen is a set of files for client (directory called
'client' is created for them) and one file for service (resides in the
same directory as the service header).
Let's take a closer look at them.
Client
files are postfixed with
_client,
e.g. my_service_client.h and my_service_client.cpp. Header contains
declaration of class you use in client to communicate with server. It's
name is the name of your original class postfixed by _client, too.
Source file (_client.cpp) implements methods as calls to server over
network. There is actually a little bit more code, but it's required to
support direct calls to server objects
(i.e. if client resides on server, it's not too smart to call methods
using network interface).
Server file's name (its a
source file) is postfixed with
_dispatch.
You should compile and link your device with it (you can link more
dispatch files
if you want to have more services in device). Server can find all
services in the device file then. Dispatch itself does the opposite of
what client does - extracts data from stream, fills variables required
for a method call and finally calls the requested method.
For more information, see
generating
communication layer.