mardi 9 mai 2017

Selecting a design pattern to assing different objects via an interface, based on a user made configuration

Currently am I working on a by user configurable controller.

The user can configure the modules which are objects of the same or different classes, all returning one or more variables as integer or boolean.

The user can configure the links between the just configured objects as they can request each others return data via a method.

A execution manager executes the highest object in the configuration of which the return values are not used by other objects. The highest object will require as configured by the user, return data from other objects via their methods. These methods "activate" the object of which data is requested, and will further down ask return data from other objects.

I am planning to write this software in c++ an shall be running on a cortex-m4 microcontroller.

I have bin looking in to several design patters but cant find any matching one, suiting my needs. So i made my own design but am not totally convinced of it being the perfect solution.

My design so far:

  • a abstract base class acts as an interface for creation.
  • a class inheriting the base class Decorates the module.

  • an other base class acts as an interface to access a single bool or integer.

  • a class inheriting the "other base class" contains the actual algorithm to access the method to retrieve the data from the module.

Meaning:

  • for every single by configuration linkable bool or integer is an object created to retrieve the data, returning it via a standard base interface.
  • this means that Every module can have any number of variables only each resulting when used in a single object per variable.

Is there any other, more efficient design pattern than my "Brand pattern", creating less overhead but also providing the same run time flexibility?

MvG Robbert

Aucun commentaire:

Enregistrer un commentaire