/** \file
 *
 *  Contains the ScheduledItem class implementation.
 *
 *  Copyright (c) 2007,2008,2009 MBARI
 *  MBARI Proprietary Information.  All Rights Reserved
 *  Created on: Dec 3, 2013
 *  Author: godin
 *
 */

#include "ScheduledItem.h"

ScheduledItem::ScheduledItem( const Str& cmd, const Str& id, int idIndex, int idCount )
    : cmd_( cmd ),
      index_( -1 ),
      id_( id ),
      idIndex_( idIndex ),
      idCount_( idCount ),
      ready_( id == Str::EMPTY_STR ),
      execTime_( Timestamp::NOT_SET_TIME ),
      executed_( false ),
      type_( NONE )
{}

Str ScheduledItem::report()
{
    if( id_ == Str::EMPTY_STR )
    {
        return Str( index_, 10 ) + ": \"" + cmd_ + "\", " + typeToStr();
    }
    else
    {
        return Str( index_, 10 ) + " (#" + idIndex_ + " of " + idCount_ + " with id='" + id_ + "'): \"" + cmd_ + "\", " + typeToStr();
    }
}

ScheduledItemASAP::ScheduledItemASAP( const Str& cmd, const Str& id, int idIndex, int idCount )
    : ScheduledItem( cmd, id, idIndex, idCount )
{
    type_ = ASAP;
}

ScheduledItemNext::ScheduledItemNext( const Str& cmd, const Str& id, int idIndex, int idCount )
    : ScheduledItem( cmd, id, idIndex, idCount )
{
    type_ = NEXT;
}

ScheduledItemTimed::ScheduledItemTimed( const Timestamp& execTime, const Str& cmd, const Str& id, int idIndex, int idCount )
    : ScheduledItem( cmd, id, idIndex, idCount )
{
    execTime_ = execTime;
    type_ = TIMED;
}
