artemis-dev / artemis

A RooT Extension with Modular processors for Instant Switching
2 stars 6 forks source link

Automatic command registration #32

Open cheese-cake opened 3 years ago

cheese-cake commented 3 years ago

Now you can register artemis command by calling the TCatCmdFactory::Register explicitly. However, all the safe commands are expected to be registered automatically. Otherwise, some useful commands will be hidden.

The convenient way maybe a combination of constructor with an argument in a base class to call a pure virtual member function which should be defined in a child class.

In source file of a child command class of TCmdXXX, you have to write when you add your own command,

TCmdXXX aCmd(TCatCmdFactory::Instance());

This constructor should call TCatCmd::TCatCmd(TCatCmdFactory::Instance()),which call a pure virtual function where the concrete command will be registered.

This scheme will be convenient in C++11 or greater version, where

shinsuke-ota commented 1 year ago

Here is useful factory class.

https://gist.github.com/sacko87/3359911

shinsuke-ota commented 1 year ago

Not command but decoder seems to be automatically registered and created.

$ artemis -l -b
Registering art::TStreamingModuleDecoderLRTDC
Use mass table inside root since Art.MassTable is not defined in .rootrc
Creating art::TStreamingModuleDecoderLRTDC
artemis [0]