//------------------------------------------------------------------------------
// <copyright file="SSQClassConfig.h" company="LiquidRobotics">
//
// Copyright (c) 2014 Liquid Robotics, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
// This software is associated with a release.  Liquid Robotics makes no
// representation that the design, interfaces or component distribution will
// remain unchanged in future releases.
//
// </copyright>
//
// <summary>
// Typedef's to configure the way Sensor template classes are used.
// </summary>
//
// <owner>Mike Cookson</owner>
//------------------------------------------------------------------------------

#ifndef __SSQClassConfig_h__
#define __SSQClassConfig_h__

#include "SensorCommandBase.h"
#include "SensorConcreteCommand.h"
#include "SensorControllerBase.h"
#include "SensorControllerBaseCmdID.h"
#include "SensorControllerExceptions.h"
#include <stdint.h>

namespace LiquidRobotics {
namespace SimpleSBDQueue {

typedef EventLib::SensorControllerBaseCommandID SSQCmdID;
typedef EventLib::SensorCommandBase<SSQCmdID> SSQControllerCommand;
typedef EventLib::SensorControllerBase<SSQControllerCommand,SSQCmdID> SSQControllerBase0Base;

class SSQControllerBase0 : public SSQControllerBase0Base
{
public:

    typedef LiquidRobotics::SMACFramework::ByteArray ByteArray;
    typedef uint16_t PriorityType;
    typedef uint16_t SenderIDType;
    typedef uint32_t SenderTransactionType;
    typedef uint32_t TTLType;

    enum QueuePosition
    {
        QUEUE_END = 0,                  // put the message at the end of the queue (FIFO)
        QUEUE_FRONT = 1,                // put the message at the start of the queue (LIFO)
        QUEUE_LATEST_AT_FRONT = 2       // put the message at the start of the queue (LIFO), but move it to the end if another message arrives (FIFO)
    };

    virtual void Start() = 0;
    virtual void Stop() = 0;
    virtual void EnqueueMessage(const PriorityType priority, const ByteArray& message, const SenderIDType senderID, const SenderTransactionType senderTransaction,
                            const QueuePosition queuePos = QUEUE_END, const TTLType timeToLive = 0) = 0;
    virtual void RequestMailboxCheck() = 0;
};

// additional class members can be added to SSQControllerBase0 in an abstract class to provide a callback
// interface from commands to the controller

typedef EventLib::SensorConcreteCommand<SSQControllerBase0,
				EventLib::SensorCommandBase<SSQCmdID>,
                                SSQCmdID,
				EventLib::SensorControllerExceptions> SSQConcreteCmd;

}
}

#endif
