/* LICENSE:
  =========================================================================
    CMPack'04 Source Code Release for OPEN-R SDK 1.1.5-r2 for ERS7
    Copyright (C) 2004 Multirobot Lab [Project Head: Manuela Veloso]
    School of Computer Science, Carnegie Mellon University
    All rights reserved.
  ========================================================================= */

#ifndef INCLUDED_BehaviorPacketDecoder_h
#define INCLUDED_BehaviorPacketDecoder_h

#include "PacketDecoder.h"

struct BehNames {
  static const int MaxNameLen  =127;
  static const int MaxTranses  =20;
  static const int MaxStates   =10;
  static const int MaxBehaviors=16;

  struct TransName {
    char name[MaxNameLen+1];
  };

  struct StateName {
    char name[MaxNameLen+1];
    TransName trans_names[MaxTranses];
  };

  struct BehName {
    char name[MaxNameLen+1];
    int num_states;
    StateName state_names[MaxStates]; 
  };

  BehName beh_names[MaxBehaviors];

  BehNames::BehNames();

  void dump();
};

/*------------------------------------------------------------------
CLASS
  BehaviorNamesPacketDecoder

DESCRIPTION
  Decodes behavior/state/transition names.
------------------------------------------------------------------*/
class BehaviorNamesPacketDecoder : public PacketDecoder {
private:
  bool decode(uchar **bufp,int *data_left,BehNames::TransName *trans_names);
  bool decode(uchar **bufp,int *data_left,BehNames::StateName *state_name);
  bool decode(uchar **bufp,int *data_left,BehNames *beh_names);
public:
  bool decode(BehNames *beh_names,RobotDataPacket *packet);
private:
};

/*------------------------------------------------------------------
CLASS
  BehaviorTracePacketDecoder

DESCRIPTION
  Decodes behavior/state/transition traces.
------------------------------------------------------------------*/
class BehaviorTracePacketDecoder : public PacketDecoder {
private:
  bool decode(uchar **bufp,int *data_left,int indent,const BehNames *beh_names);
public:
  bool decode(RobotDataPacket *packet,const BehNames *beh_names);
private:
};

#endif
