Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
  •  Bunch pattern server: Have tail cleanup keep N bunches Lars Froehlich
  •  Wavelength control server: Implement offset in terms of phase Lars Froehlich Olaf Hensler
  •  Decide whether to implement a doocs::Server class in serverlib (see below)
  •  Create jddd panels for stand-alone bunch pattern servers  Lars Froehlich
  •  Magnet ML server: Calculate a maximum field error when a magnet is uncycled Lars Froehlich
  •  Big brother server: Implement Soft-EPS Lars Froehlich

doocs::Server class

The goals are:

- Give the server programmer more control over its own main() if desired
- Provide an alternative way of customizing server behavior
  than providing linker objects for functions such as
  eq_cancel(), eq_init_epilog(), interrupt_usr1_prolog() etc.
- Full backwards compatibility with existing DOOCS servers

To accomplish this, I have created a branch "feature/add_server_class" that implements a doocs::Server class. See:

http://doocs-git.desy.de/cgit/doocs/library/common/serverlib.git/tree/?h=feature/add_server_class

The doocs::Server class offers virtual functions that can be used as customization points instead of the familiar post_init_epilog(), interrupt_usr1_prolog() etc. group of functions. Additionally, the server object can - over time - absorb more of the symbols that are now cluttering the global namespace.

With the new feature, there are several ways to write a DOOCS server:

1)
Provide nothing. All necessary functions are provided as weak symbols by the serverlib:

#include <eq_server.h>

// These two symbols still have to be provided, but they could
// also be incorporated into the Server class.
const char* object_name = "test_server";
EqFct *eq_create(int eq_code, void*) { return nullptr; }


2)
Provide code for one or more of the "special functions". The user's strong symbol replaces serverlib's weak one:

#include <eq_server.h>
const char* object_name = "test_server";
EqFct *eq_create(int eq_code, void*) { return nullptr; }

void post_init_epilog ()
{
    printtostderr(__func__, "After init()");
}


3)
Provide a custom main function (this can be freely combined with option 2):

#include <eq_server.h>
const char* object_name = "test_server";
EqFct *eq_create(int eq_code, void*) { return nullptr; }

int main(int argc, char *argv[])
{
    doocs::Server server;

    printtostderr(__func__, "We're in our own main()");
    server.run(argc, argv);
    printtostderr(__func__, "Leaving our own main()");
}


4)
Customize the server class itself:

#include <eq_server.h>
const char* object_name = "test_server";
EqFct *eq_create(int eq_code, void*) { return nullptr; }

class MyServer : public doocs::Server
{
    void init_epilog() override
    {
        printtostderr(__func__, "After init()");
    }
};

int main(int argc, char *argv[])
{
    MyServer server;
    server.run(argc, argv);
}