/**
 * @file
 * $Id$
 * $Revision$
 * $Author$
 * $Date$
 *
 * This file is a part of The iWear Framework.
 * In particular is this file a part of the Framework context 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 __LOGICCONTEXT_TERM_H
#define __LOGICCONTEXT_TERM_H

#ifndef __CONTEXTPART_H
#include <iwear-context/contextpart.h>
#endif

#ifndef __CONTEXTENUMS_H
#include <iwear-context/contextenums.h>
#endif

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

#include <list>

using namespace std;

namespace iwear{ 
namespace context{

/**
 * This is a subclass of class ContextPart. In this class the value of
 * a ContextPart should be evaluated with the get_value method. 
 * 
 * A ContextPart can not only be a simple LogicCompositeContext
 * but also a complex term, which be composed of for example a
 * LogicCompositeContext and two other LogicContextTerms.
 */
class LogicContextTerm : public ContextPart{
private:

    /**
     * A logic relation ('AND' or 'OR'). The value of a ContextPart 
     * is evaluated with it.  
     */
    LogicRelation logic_relation;

    /**
     * A list of ContextParts, in which the structure of a
     * LogicCompositeContext or a LogicContextTerm should be saved.
     */
    list<ContextPart*>* context_part_list;
protected:
public:

    /**
     * The constructor to be used to creat a new LogicContextTerm.
     */
    LogicContextTerm(void);

    /**
     * The destructor.
     */    
    virtual ~LogicContextTerm(void);

    /**
     * Set the logic_relation. 
     * @param LogicRelation new_logic_relation    
     */
    void set_logic_relation(LogicRelation new_logic_relation);
    
    /**
     * Get (evaluate) the value of a ContextPart. This method
     * evaluates the ContextPart by getting the values of the
     * children and combining them with the logic_relation to the
     * value of this ContextPart.
     * It reimplements the get_value method of it's fatherclass
     * @return bool
     */
    virtual bool get_value(void) const;

    /**
     * Add a child (ContextPart) to the list of ContextParts 
     * @param ContextPart context_part
     */    
    void add_context_part(ContextPart* context_part);

}; // class LogicContextTerm

}  // namespace context
}  // namespace iwear

#endif	//__LOGICCONTEXT_TERM_H

