#ifndef _DYNOCOMMAND_H
#define _DYNOCOMMAND_H

#include "LayeredControlIF.h"
#include "MessageQueue.h"
#include <string.h>

#define DynoInputQueueName  "dynoInCommand"
#define DynoOutputQueueName "dynoOutCommand"

class DynoCommand : public MessageQueue {
 public:
    enum DynoCommands {
	None = 0,
  // other
	setNewBehaviorTimeoutLimit,
	
  // append
	appendBehaviors,
  appendBehaviorsAck,
  appendBehaviorsNack,
  
  // insert
	insertBehaviors,
  insertBehaviorsAck,
  insertBehaviorsNack,
  
  // delete
	deleteBehavior,
  deleteBehaviorAck,
  deleteBehaviorNack
    };

    struct Command {
	DynoCommands _cmd;
	long  _behaviorId;
	short _arg1;
	LayeredControlIF::Status _arg2;
  LayeredControlIF::BehaviorFilename _file;

      Command() {
	_cmd = DynoCommand::None;
	_behaviorId = 0;
	_arg1 = 0;
	_arg2 = LayeredControlIF::Ok;
      };

  // Response (ack or nack, and status)
      Command(DynoCommand::DynoCommands cmd,
              LayeredControlIF::Status stat = LayeredControlIF::Ok) {
	_cmd = cmd;
	_behaviorId = 0;
	_arg1 = 0;
	_arg2 = stat;
      };

  // Delete behavior (cmd and behavior id)
      Command(DynoCommand::DynoCommands cmd, long id) {
	_cmd = cmd;
	_behaviorId = id;
	_arg1 = 0;
	_arg2 = LayeredControlIF::Ok;
      };
       
  // Append behaviors (cmd and filename containing behaviors)
      Command(DynoCommand::DynoCommands cmd,
              LayeredControlIF::BehaviorFilename file) {
	_cmd = cmd;
	strncpy(_file, file, sizeof(_file) -1);
	_behaviorId = 0;
	_arg1 = 0;
	_arg2 = LayeredControlIF::Ok;
      };

  // Insert behaviors (cmd, filename containing behaviors, and 
  // behavior id to insert before)
      Command(DynoCommand::DynoCommands cmd,
              LayeredControlIF::BehaviorFilename file, long id) {
	_cmd = cmd;
	strncpy(_file, file, sizeof(_file) -1);
	_behaviorId = id;
	_arg1 = 0;
	_arg2 = LayeredControlIF::Ok;
      };
  };

    DynoCommand( MessageQueue::Access access, const char *name );
    ~DynoCommand();

    int read( Command *cmd );
    int write( Command *cmd );

 protected:

 private:

};

#endif
