/* 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_T_ABSTRACT_VALUE_CONSTRUCTOR_HPP
#define NMM_T_ABSTRACT_VALUE_CONSTRUCTOR_HPP NMM_T_ABSTRACT_VALUE_CONSTRUCTOR_HPP

#include "nmm/nmm_prefix.hpp"

#include "ValueConstructor.hpp"

namespace NMM {

  /** Abstract constructor for an non-Value type.
   * This class is a template factory object for the ValueFactory.
   * It creates objects of a type which is not a subclass of TValue.
   *
   * This class defines the abstract createObject() method.
   * It is needed for serializing polymorphic pointers of abstract type.
   */
  template <class T>
  class TAbstractValueConstructor : public ValueConstructor {
  public:
    /** @name Constructor & Destructor
     */
    //@{
    /** Constructor.
     * This constructor registers the object at the ValueFactory.
     *
     * @param ti Type information of type of objects this factory object creates
     */
    TAbstractValueConstructor(const TypeInfo& ti)
      :  ValueConstructor(ti)
    {}

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

    /** @name Factory method
     */
    //@{
    /** Create an object.
     * 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 creates a plain object of type T.
     *
     * @return Pointer to the created object
     */
    virtual T* createObject() const = 0;
    //@}
  };
  
}

#include "nmm/nmm_suffix.hpp"

#endif
