// $Source: /usr/local/SimSoft/SoftShop/Identity/IdObject.h,v $
// $Revision: 1.19 $
// $Author: baum $
// $Date: 2001/11/29 15:52:23 $
//
// Login name of the user who locked the revision
// $Locker:  $
// Tag name used to checkout the file
// $Name: Release-20 $
// State assigned to revision
// $State: Exp $
//
//
// $Log: IdObject.h,v $
// Revision 1.19  2001/11/29 15:52:23  baum
// -In Kalender.cpp und Kalender.h Handsteuerung eingebaut
//

#ifndef _IDOBJECT_H
#define _IDOBJECT_H  1

#ifndef __BORLANDC__
#define __rtti
#endif

#ifdef __linux
#include <typeinfo>
#else
#include <typeinfo.h>
#endif

#include <iostream.h>

#include "DynArray.h"
#include "Map.h"

#ifdef _IDENTITY_CPP
#  undef _impexp
#  define _impexp __declspec(dllexport)
#elif defined BUILD_IDENTITY_DLL
#  undef _impexp
#  define _impexp
#else
#  undef _impexp
#  define _impexp __declspec(dllimport)
#endif

#if defined __GNUG__ || defined __hpux
#  undef _impexp
#  define _impexp
#endif

//==================================================================
//		Class-Header
//		for class Identity
//==================================================================

//##ModelId=4030D769029F
class _impexp __rtti Identity
  {
  public:
    // destructor
	//##ModelId=4030D76902AF
    virtual ~Identity ();

    // yielding the Type
	//##ModelId=4030D76902B1
    const char* Type () const;

    // yielding and/or modifying the Name
	//##ModelId=4030D76902B3
    const char* Name () const;
	//##ModelId=4030D76902B5
    const char* setName (const char* newName);

    // Identity-output to a stream
	//##ModelId=4030D76902BF
    virtual ostream& print (ostream&) const;

    // Identity-output to a stream
	//##ModelId=4030D76902C2
    virtual void stream (ostream&) const = 0;

    // retrieve the DynArray in which Objects of the given Type are stored
	//##ModelId=4030D76902C5
    static DynArray<Identity> *TypeArray (const type_info& type);

    // retrieve Object by Type & Name
	//##ModelId=4030D76902D0
    static Identity* find (const type_info& type, const char* name);

  protected:
    // constructors
	//##ModelId=4030D76902D4
    Identity (const char* name);
	//##ModelId=4030D76902DF
    Identity (const Identity&);

    // register an object to enable its retrieval via find ()
    //  (should be called by all constructors of instantiable classes
    //   derived from Identity)
	//##ModelId=4030D76902E1
    void enList ();

    // clean all empty Lists for Types
	//##ModelId=4030D76902E2
    static void clean ();

  private:
    // default constructor, declared but not defined
	//##ModelId=4030D76902EF
    Identity ();

    // assignment operator, declared but not defined
	//##ModelId=4030D76902F0
    Identity& operator = (const Identity&);

    // register this in da to enable its retrieval via find ()
	//##ModelId=4030D76902FD
    void enList (DynArray<Identity> *da);

    // unregister an object
	//##ModelId=4030D76902FF
    void outList ();

    // adjust the name if necessary
	//##ModelId=4030D7690300
    void corrName ();

    // return the DynArray in which the Object should be stored
	//##ModelId=4030D769030D
    DynArray<Identity> *TypeArray () const;

    // data members
	//##ModelId=4030D769030F
    char* ObjName;
	//##ModelId=4030D769032E
    DynArray<Identity> *ObjArray;

    // this is a Map of DynArrays in which all enList()ed objects are kept
    #if defined(__BORLANDC__) || defined(_MSC_VER)
      // sorry Ladies & Gentlemen, Borland's rtti requires this weirdness
	//##ModelId=4030D769033D
      static Map<char, DynArray<Identity> > ClassTypes;
    #elif defined __linux
      static Map<const type_info, DynArray<Identity> > ClassTypes;
    #endif
};	// class Identity


// Identity-output to a stream (simply calls print ())
inline ostream& operator << (ostream& ostrm, const Identity& id) {
  return id.print (ostrm);
}

#endif // !_IDOBJECT_H

