/*

ARIA header files for use with ARNL 1.7.1

Copyright(C) 2004, 2005 ActivMedia Robotics, LLC. 
Copyright(C) 2006, 2007, 2008, 2009 MobileRobots Inc.
All rights reserved.

This copy of Aria was relicensed for use with Arnl and the Arnl
license by MobileRobots Inc.  If you wish to download a seperate
distribution of Aria licensed under the GPL or a commercial license go to
http://www.mobilerobots.com/SOFTWARE/aria.html or contact MobileRobots
Inc, at robots@mobilerobots.com or MobileRobots Inc,
10 Columbia Drive, Amherst, NH 03031; 800-639-9481

MobileRobots Inc hereby grants to other individuals or
organizations permission to use this software with Arnl and in
compliance with the Arnl license.  This software may not be
distributed to others except by MobileRobots Inc.

MobileRobots Inc does not make any representations about the
suitability of this software for any purpose.  It is provided "as is"
without express or implied warranty.

*/
#ifndef ARSERVERDATA_H
#define ARSERVERDATA_H

/// class to hold information about the different data the server has
/**
   This class is mostly just for holding all the information about one
   of the server data entires in one convenient spot
**/

#include "Aria.h"

class ArServerClient;
class ArNetPacket;


class ArServerData
{
public:
  /// Constructor
  AREXPORT ArServerData(
	  const char *name, const char *description, unsigned int command,
	  ArFunctor2<ArServerClient *, ArNetPacket *> *functor,
	  const char *argumentDescription, const char *returnDescription,
	  const char *commandGroup = NULL, const char *dataFlags = NULL,
	  ArRetFunctor1<long, unsigned int> *getFrequencyFunctor = NULL,
	  ArFunctor2<long, unsigned int> *requestChangedFunctor = NULL, 
	  ArFunctor2<ArServerClient *, ArNetPacket *> 
	  *requestOnceFunctor = NULL);
  /// Destructor
  AREXPORT virtual ~ArServerData();
  const char *getName(void) { return myName.c_str(); }
  const char *getDescription(void) { return myDescription.c_str(); }
  unsigned int getCommand(void) { return myCommand; }
  ArFunctor2<ArServerClient *, ArNetPacket *> *getFunctor(void) 
    { return myFunctor; };
  const char *getArgumentDescription(void) 
    { return myArgumentDescription.c_str(); }
  const char *getReturnDescription(void) 
    { return myReturnDescription.c_str(); }
  const char *getCommandGroup(void) 
    { return myCommandGroup.c_str(); }
  ArFunctor2<ArServerClient *, ArNetPacket *> *getRequestOnceFunctor(void)
    { return myRequestOnceFunctor; }
  AREXPORT bool hasDataFlag(const char *dataFlag);
  AREXPORT bool addDataFlags(const char *dataFlags);
  AREXPORT bool remDataFlag(const char *dataFlag);
  bool isSlowPacket(void) { return mySlowPacket; }
  bool isIdlePacket(void) { return myIdlePacket; }
  const char *getDataFlagsString(void) 
    { return myDataFlagsBuilder.getFullString(); }
  AREXPORT void callRequestChangedFunctor(void);
protected:
  std::string myName;
  std::string myDescription;
  std::string myArgumentDescription;
  std::string myReturnDescription;
  std::string myCommandGroup;
  std::string myRawDataFlags;
  ArMutex myDataMutex;
  ArArgumentBuilder myDataFlagsBuilder;
  unsigned int myCommand;
  ArFunctor2<ArServerClient *, ArNetPacket *> *myFunctor;
  ArRetFunctor1<long, unsigned int> *myGetFrequencyFunctor;
  ArFunctor2<long, unsigned int> *myRequestChangedFunctor;
  ArFunctor2<ArServerClient *, ArNetPacket *> *myRequestOnceFunctor;
  bool mySlowPacket;
  bool myIdlePacket;
};

#endif // ARSERVERDATA_H
