/**
 * $Id$
 * $Revision$
 * $Author$
 * $Date$
 *
 * This file is part of The iWear Framework.
 * In particular this file is part of the uiservices library
 *
 * The iWear Framework is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by the
 * Free Software Foundation as in version 2 of the License.

 * 
 * The iWear Framework is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 * more details.
 * 
 * You should have received a copy of the GNU General Public License along with
 * The iWear Framework; if not, write to the Free Software Foundation, Inc., 59
 * Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

#ifndef __EXPORTABLEMENU_H
#define __EXPORTABLEMENU_H

// Standard includes
#include <string>
#include <iostream>
#include <algorithm>
#include <vector>

// iWear includes
#include <iwear/threadlocked.h>
#include <iwear/debugstream.h>
#include <iwear/utility.h>
#include <iwear_uiservices/exportablemenunode.h>

using namespace std;

namespace iwear {
namespace uiservices {

/**
 * Exportable version of a menu which is like a copy of the whole
 * menu (including the structure).
 * @author Carsten Rachuy
 */
class ExportableMenu : public ThreadLocked {

 public:
    
    /**
     * Constructor
     */
    ExportableMenu(const               string name, 
		   const               string description, 
		   uint32_t            selected_element,
		   ExportableMenuNode* exportable_menu_node);

    /**
     * Destructor
     */
    virtual ~ExportableMenu(void);

    /**
     * @return the name
     */
    inline string get_name(void){
	return this->name;
    }

    /**
     * @return the description
     */
    inline string get_description(void){
	return this->description;
    }

    /**
     * @return the description
     */
    inline uint32_t get_selected_element(void){
	return this->selected_element;
    }


    /**
     * @return the exportable menu node
     */
    inline ExportableMenuNode* get_exportable_menu_node(void){
	return this->exportable_menu_node;
    }

    /**
     * @return the current active layer
     */
    const vector<ExportableMenuNode*>& get_currently_active_layer(void);
    

    /**
     * Equality
     * @param external_menu_node The MenuNode which should be compared
     *        to the actual one
     */
    inline bool operator==(ExportableMenu& exportable_menu){
	ThreadLocker tl(Mutex);
        return ( this->exportable_menu_node->get_id() == 
		 exportable_menu.get_exportable_menu_node()->get_id() );
    }
    

    /**
     * Inequality
     * @param exportable_menu_node The MenuNode which should be compared
     *        to the actual one     
     */    
    inline bool operator!=(ExportableMenu& exportable_menu){
	ThreadLocker tl(Mutex);
        return !(*this == exportable_menu);
    }
 

 private:

    /**
     * Name of the menu
     */
    string name;
    
    /**
     * Description of the menu
     */
    string description;

    /**
     * Selected element
     */
    uint32_t selected_element;
    
    /**
     * External menu node
     */
    ExportableMenuNode* exportable_menu_node;

   
};
 

} // namespace uiservices
} // namespace iwear


#endif // __EXPORTABLEMENU_H

