/**
 * outputadvisor.h - is part of the iwear_output-advisor
 * @file
 * $Id$
 * $Revision$
 * $Author$
 * $Date$
 *
 * This file is part of The iWear Framework.
 * In particular this file is part of the Framework Output 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 __OUTPUTADVISOR_H
#define __OUTPUTADVISOR_H

#ifndef __OUTPUTDATA_H
#include <iwear_output/outputdata.h>
#endif

#ifndef __OUTPUTMANAGER_H
#include <iwear_output/outputmanager.h>
#endif

#ifndef __EXCEPTIONS_H
#include <iwear/exceptions.h>
#endif

#ifndef __THREADLOCKER_H
#include <iwear/threadlocker.h>
#endif

#include <vector>
#include <stdint.h>


namespace iwear { 
    namespace output {

/** 
 * Can check what's the best output method in the current context.
 */
class OutputAdvisor : public virtual ThreadLocked\
{

 private:
	    
    /** Pointer to a ContextManager instance. */
    //	ContextManager* context_manager;
    
    /** 
     * Pointer to the OutputManager. 
     */
    OutputManager* output_manager;
	
    /** Monitored Outputs. The uid of the ODO as key and all functors
     * registered at the odo as values. */
    //	multimap<const uid*, ODOChangedFunctor*, deref_less<const uid*> > monitored_outputs;
    // maybe a map for index_of_monitored_context <-> OutputData::UID

 public:

    /**
     * The standard constructor for this class.
     * @param output_manager the OutputManager that will receive our advice.
     * @todo We will need a constructor that gets a ContextManager soon.
     */
    OutputAdvisor(OutputManager* output_manager);

    /** Delete all objects from memory that where created with new and 
     * should not outlast the OutputAdvisor. 
     * @note Maximum one means the minimum can be zero. */
    virtual ~OutputAdvisor();
	
    /** Changes a value of the Object that  determines the output-method. 
     * May return an error-code. 
     * @param output_data refers to the OutputData that should be advised.
     * @param monitor is a flag to say it the output should be advised while
     * 	it is on the output.
     * @return A status flag that says what happend on the advise.
     *  (errorcode)
     */
    uint32_t advise(OutputData* output_data, bool monitor);
	
    /** Get OutputDatas that are currently monitored by the OutputAdvisor.
     * @return a vector of OutputData pointers with all monitored outputs. 
     */
    //	inline vector<pair<OutputData*, uid*>* >& get_monitored_outputs(){
    //	    return monitored_outputs;
    //	}

    /** 
     * Removes an OutputData from the list of monitored outputs. 
     * @param output_data the OutputData that should be removed from
     * monitoring.
     *
     * @return the status of the remove.
     */
    bool stop_advising(OutputData* output_data);
	
    /**
     * Is called when an option in an outputdata we are listening on is
     * changed.
     * @param odo_uid the unique id of the odo the eventable belongs to.
     * @param ces_name the name of the ContainedEventSource that triggered
     * the event.
     * @param event_name the name of the event triggered by the
     * ContainedEventSource of an OutputData.
     */
    //	virtual void on_odo_changed(const uid* odo_uid, const string& ces_name, const string& event_name);

    }; // class OutputAdvisor
} // namespace output
} // namespace iwear
#endif	//__OUTPUTADVISOR_H

