/*

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 ARSERVERINFODRAWINGS_H
#define ARSERVERINFODRAWINGS_H

#include "Aria.h"
#include "ArServerBase.h"

class ArServerClient;

/** Service to provide clients with information about graphical figures to be
 displayed with the map.  

 Use addDrawing() to add a figure, or use addRangeDevice() or 
 addRobotsRangeDevice() to automatically create standard drawings for 
 range devices.

 Clients may use the <code>listDrawings</code> data
 request to receive a list of figures and metadata about those figures.
 The reply packet to the <code>listDrawings</code> request is as follows:
 <ol>
  <li>Number of figures (4-byte integer)Then, for each figure, the following values are given
  <li>For each figure:
    <ol>
      <li>Figure name (null-terminated string)</li>
      <li>Shape ID (null-terminated string)</li>
      <li>Primary color: <ol>
          <li>Unused (byte)</li>
          <li>Red (byte)</li>
          <li>Green (byte)</li>
          <li>Blue (byte)</li>
      </ol></li>
      <li>Shape size (4-byte integer)</li>
      <li>Layer number (4-byte integer)</li>
      <li>Suggested refresh time (4-byte integer)</li>
      <li>Secordary color: <ol>
          <li>Unused (byte)</li>
          <li>Red (byte)</li>
          <li>Green (byte)</li>
          <li>Blue (byte)</li>
      </ol></li>
    </li>
   </ol>
  </ol>

 This command is in the <code>SensorInfo</code> permission group for users.
*/
class ArServerInfoDrawings
{
public:
  /// Constructor
  AREXPORT ArServerInfoDrawings(ArServerBase *server);
  /// Destructor
  AREXPORT virtual ~ArServerInfoDrawings();
  /// Adds a shape to the set of figures
  AREXPORT bool addDrawing(ArDrawingData *drawingData, const char *name,
		   ArFunctor2<ArServerClient *, ArNetPacket *> *functor);
  /// Adds a specific range device to be drawn (using its default shape)
  AREXPORT bool addRangeDevice(ArRangeDevice *rangeDevice);
  /// Adds all of the robot's range devices (using their default shape)
  AREXPORT bool addRobotsRangeDevices(ArRobot *robot);
  /// Client callback: Puts the list of shapes that can be drawn and their metadata into a reply packet (internal use mostly)
  AREXPORT void netListDrawings(ArServerClient *client, ArNetPacket *packet);

  AREXPORT void netGetDrawingList(ArServerClient *client, ArNetPacket *packet);

  /// Client callback utility: Puts the current data for the given range device into a reply packet (internal use mostly)
  AREXPORT void netRangeDeviceCurrent(ArServerClient *client, 
				      ArNetPacket *packet,
				      ArRangeDevice *device);
  /// Client callback utilit: Puts the cumulative buffer of the given range device into a reply packet (internal use mostly)
  AREXPORT void netRangeDeviceCumulative(ArServerClient *client, 
					 ArNetPacket *packet,
					 ArRangeDevice *device);

protected:
  ArServerBase *myServer;
  std::map<std::string, ArDrawingData *, ArStrCaseCmpOp> myDrawingDatas;
  std::map<std::string, ArFunctor *, ArStrCaseCmpOp> myDrawingCallbacks;
  ArFunctor2C<ArServerInfoDrawings, ArServerClient *, ArNetPacket *> myNetListDrawingsCB;  
  ArFunctor2C<ArServerInfoDrawings, ArServerClient *, ArNetPacket *> myNetGetDrawingListCB;  
};


#endif
