The new class definition

Every scheduler class has to inherit from the UserScheduler class. The only redefinition needed is the aggregate function. But, the init, serialize and deserialize functions have to be declared conforming to the C++ standard (but not defined - the inherited functions are sufficient). The following example shows a simple scheduler class implementation.
class MyScheduler : public UserScheduler {
public:
  static const char* stName;

  MyScheduler();
  ~MyScheduler();
  void init();

  static char* serialize(MyScheduler* GS);
  static MyScheduler* deserialize(const char* serializedScheduler);
  /* Overriden UserScheduler class aggregate method. */
  int aggregate(corba_response_t* aggrResp, size_t max_srv,
                const size_t nb_responses, const corba_response_t* responses);
};

const char* MyScheduler::stName="UserGS";

MyScheduler::~MyScheduler() {

}

MyScheduler::MyScheduler() {
  this->name = this->stName;
  this->nameLength = strlen(this->name);
}

int MyScheduler::aggregate(corba_response_t* aggrResp, size_t max_srv,
                            const size_t nb_responses,
                            const corba_response_t* responses)
{
  ...
}

SCHEDULER\_CLASS(MyScheduler)
After defining the scheduler class, the developer just has to use the SCHEDULER_CLASS macro to define it as a scheduler class loadable from an agent.

In our example, the call to SCHEDULER_CLASS(MyScheduler) - after the class declaration - makes the class loadable by a DIET agent.



The DIET Team - Mer 29 nov 2017 15:13:36 EST