#ifndef _LIBSTTERM_COMMAND_H_
#define _LIBSTTERM_COMMAND_H_
#include <stdio.h>      // printf

//#define PRE_SECTION ".data."
//#define SUB_SECTION "commands"
#define PRE_SECTION ""
#define SUB_SECTION "commands"

#define STTERM_COMMAND(a) const createFuncType createFunc ## a __attribute__ ((section ( PRE_SECTION SUB_SECTION), used)) = createInstance_ ## a;
#define EXT_STTERM_COMMAND(a) \
      extern const CCommand * createInstance_ ## a(); \
      const createFuncType createFunc_ ## a __attribute__ ((section ( PRE_SECTION SUB_SECTION), used)) = createInstance_ ## a;
#define STTERM_REFFER_COMMAND(a) \
      extern const CCommand * createInstance_ ## a(); \
      const createFuncType createFunc_ ## a __attribute__ ((section ( PRE_SECTION SUB_SECTION "_"), used)) = createInstance_ ## a;

#define KEEPER(a) \
      const void *keeper_ ## a __attribute__ ((section ( PRE_SECTION "keeper_" ), used)) = (void *)&a;

//#define STTERM_COMMAND static const createFuncType createFunc __attribute__ ((used)) = createInstance;

class CPlatform;
class CCommand
{
   private:
      const char *m_pName;
      const char *m_pHelpString;
   public:
      CCommand(const char *name, const char *helpString);
      ~CCommand()=default;
      const char*getName() const
      {
         return(m_pName);
      }

      virtual int exec(int argc, const char * argv[]) const = 0;
      void printHelp() const;
};


typedef const CCommand *(*createFuncType)(void);

#endif // ? ! _LIBSTTERM_COMMAND_H_
