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

#ifndef MISSIONNODE_H_
#define MISSIONNODE_H_

class TiXmlNode;

/** \ingroup missionScript
 *
 *  Wraps a TiXmlNode.
 *
 */
class MissionNode
{
public:

    MissionNode( const char* rootName );

    virtual ~MissionNode();

    const char* getName();

    const char* getTextValue();

    bool hasChildNodes();

    MissionNode* getChild( const char* name );

    MissionNode* getFirstChild( bool ignoreTextNodes = true );

    MissionNode* getNextSibling( bool ignoreTextNodes = true );

    bool hasAttribute( const char* name );

    const char* getAttribute( const char* name );

    bool isElement();

    bool isText();

    const char* getAttribute( const char* name, int& writeTo );

    const char* getAttribute( const char* name, double& writeTo );

    bool setAttribute( const char* name, const char* value );

    bool setAttribute( const char* name, const int value );

    bool setAttribute( const char* name, const double value );

    const char* getChildTextValue();

    void setName( const char* name );

    MissionNode* appendChild( const char* name );

    MissionNode* appendChildText( const char* text );

    MissionNode* insertChildBefore( MissionNode* insertBefore, const char* name );

    MissionNode* insertChildAfter( MissionNode* insertAfter, const char* name );

    void holdNode( MissionNode* node )
    {
        heldNode_ = node;
    }

    // Print out the document as xml.
    // Only possible from the root node.
    void debugPrint();

protected:

    MissionNode( TiXmlNode* xmlNode );

    TiXmlNode* xmlNode_;

    MissionNode* heldNode_;

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

};

#endif /* MISSIONNODE_H_ */
