/** \file
 *
 *  Contains the Assign class definition.
 *
 *  Copyright (c) 2007,2008,2009 MBARI
 *  MBARI Proprietary Information.  All Rights Reserved
 */

#ifndef TOUCH_H_
#define TOUCH_H_

#include "component/Behavior.h"

class DataWriter;
class MissionItem;
class MissionNode;
class ValueClause;

/**
 *  Behavior that is embedded in scripted code within a mission file.
 *
 *  \ingroup missionScript
 */
class Assign: public Behavior
{
public:
    static Assign* Instance( MissionNode* node, const Str& itemName, MissionItem* missionItem, Logger& logger );
    virtual ~Assign();
    virtual void initialize();
    virtual void run();
    virtual bool runIfUnsatisfied();
    virtual void uninitialize();

protected:

    friend class Aggregate;

    /// Protected constructor
    Assign( const Str& name, const ElementURI& uri, ValueClause* valueClause = NULL, bool ignoreTouch = true );

    /// The writer whose timestamp is set;
    DataWriter* writer_;

    /// Reads the valueClause, if any
    ValueClause* valueClause_;

    /// If true, don't check if values have changed since last run
    bool ignoreTouch_;

    /// Initially true, then false after the first run
    bool firstRun_;

private:
    // Note that the copy constructor below is private and not given a body.
    // Any attempt to call it will return a compiler error.
    Assign( const Assign& old ); // disallow copy constructor
};

#endif /* TOUCH_H_ */
