/* Network-Integrated Multimedia Middleware (NMM)
 * http://www.motama.com/nmm.html
 *  
 * Copyright (C) 2006-2007
 * Motama GmbH, Saarbruecken, Germany
 * http://www.motama.com
 *  
 * This file is part of NMM. 
 * 
 * NMM 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; only version 2 of the License.      
 * 
 * NMM 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 NMM; if not, write to the Free Software Foundation,    
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 */
#ifndef NMM_VALUE_CONSTRUCTOR_HPP
#define NMM_VALUE_CONSTRUCTOR_HPP NMM_VALUE_CONSTRUCTOR_HPP

#include "nmm/nmm_prefix.hpp"

#include "TypeInfo.hpp"
#include "visibility.hpp"

using namespace std;

namespace NMM {

  class Value;

  /** A factory object for the ValueFactory.
   * This class is abstract factory object for the ValueFactory. It creates objects of type Value
   * with optional TValue wrappers. Two standard Template subclasses exist for types which are
   * subclasses of Value and types which are not subclasses of TValue.
   *
   * A value constructor is created as a global object. It automatically registers and unregisters
   * itself at the ValueFactory.
   */
  class DLLEXPORT ValueConstructor {
  public:
    /** @name Constructor & Destructor
     */
    //@{
    /** Constructor.
     * This constructor registers the object at the ValueFactory.
     *
     * @param ti Type information for type of objects this factory object creates
     */
    ValueConstructor(const TypeInfo& ti);

    /** Copy constructor.
     * This copy constructor is used by the ValueFactory.
     *
     * @param vc Object to copy from
     */
    ValueConstructor(const ValueConstructor& vc);

    /** Virtual destructor.
     */
    virtual ~ValueConstructor();

    /** Virtual copy constructor.
     * This copy constructor is used by the ValueFactory.
     *
     * @return A copy of this object which has the same type
     */
    virtual ValueConstructor* copy() const = 0;
    //@}

    /** @name Factory Methods
     */
    //@{
    /** Create a value.
     * This method creates a new object. It must be implemented in a subclass.
     * The caller of this method is responsible for deleting the object.
     *
     * This method always creates a Value object, using a TValue wrapper only if necessary.
     *
     * @return Pointer to the created object
     */
    virtual Value* createValue()     const = 0;

    /** Create a wrapped value.
     * This method creates a new object. It must be implemented in a subclass.
     * The caller of this method is responsible for deleting the object.
     *
     * This method always creates a TValue wrapped object, i.e. the result is of type TValue<S*>.
     *
     * @return Pointer to the created object
     */
    virtual Value* createTValue()    const = 0;

    /** Create a wrapped pointer value.
     * This method creates a new object. It must be implemented in a subclass.
     * The caller of this method is responsible for deleting the object.
     *
     * This method always creates a TValue wrapped pointer to an object, i.e. the result is of type TValue<S*>.
     *
     * @return Pointer to the created object
     */
    virtual Value* createTPointerValue() const = 0;
    //@}
  private:
    TypeInfo  __type_info;        ///< Type info of type of objects this factory object creates
    bool      __register_value;   ///< This constructor is registered at the ValueFactory
  };
  
}

#include "nmm/nmm_suffix.hpp"

#endif
