/* Template.c  -- example implementation of an NIH Library class

	THIS SOFTWARE FITS THE DESCRIPTION IN THE U.S. COPYRIGHT ACT OF A
	"UNITED STATES GOVERNMENT WORK".  IT WAS WRITTEN AS A PART OF THE
	AUTHOR'S OFFICIAL DUTIES AS A GOVERNMENT EMPLOYEE.  THIS MEANS IT
	CANNOT BE COPYRIGHTED.  THIS SOFTWARE IS FREELY AVAILABLE TO THE
	PUBLIC FOR USE WITHOUT A COPYRIGHT NOTICE, AND THERE ARE NO
	RESTRICTIONS ON ITS USE, NOW OR SUBSEQUENTLY.

Author:
	K. E. Gorlen
	Bg. 12A, Rm. 2033
	Computer Systems Laboratory
	Division of Computer Research and Technology
	National Institutes of Health
	Bethesda, Maryland 20892
	Phone: (301) 496-1111
	uucp: uunet!nih-csl!keith
	Internet: keith@alw.nih.gov
	February, 1987

Function:
	
Modification History:

$Log:	Template_c,v $
# Revision 2.204  89/10/07  23:22:02  keith
# Pre-release
# 
# Revision 2.203.1.2  89/09/21  22:59:13  keith
# Change _castdown() parameter name to "target".
# 
# Revision 2.203.1.1  89/08/30  22:03:28  keith
# Implement deepenVBase().
# 
# Revision 2.203  89/08/10  10:32:55  keith
# Pre-release
# 
# Revision 2.202.1.6  89/08/08  11:38:43  keith
# Fix up comments for Appendix A.
# 
# Revision 2.202.1.5  89/07/11  11:59:06  keith
# Fix MI _castdown() -- return q instead of p.
# 
# Revision 2.202.1.4  89/07/10  21:54:19  keith
# Fix MI version of _castdown() to work for DAGs with
# virtual base classes.
# 
# Revision 2.202.1.3  89/07/08  19:13:11  keith
# Add initialization of virtual base Object to readFrom() constructors
# 
# Revision 2.202.1.2  89/07/07  13:57:43  keith
# Add support for MI option
# 
# Revision 2.202.1.1  89/07/01  21:56:27  keith
# Base revision for R2.00 MI version
# 
# Revision 2.202  89/06/22  20:56:30  keith
# Base revision for AT&T C++ R2.0 release (Cycle 20)
# 
# Revision 2.201.1.2  89/06/22  17:01:39  keith
# Update comments about order of member class instance
# construction.
# 
# Revision 2.201.1.1  89/06/21  12:57:47  keith
# Replace downward casts from Object by calls to castdown().
# Add explicit base class names to constructor initializer lists.
# 
# Revision 2.201  89/05/12  11:20:50  keith
# Release for R2.0 Beta test.
# 
# Revision 2.200.1.2  89/05/12  11:02:40  keith
# Revised Object I/O.
# 
# Revision 2.200.1.1  89/04/24  17:19:24  keith
# Working revision for R2.0 Beta 6++
# 
# Revision 2.200  89/04/17  23:31:53  keith
# Base revision for R2.0 Beta 6.
# 
# Revision 2.121  89/02/16  11:10:11  keith
# Base revision for C++ R1.2.1 compatible version.
# 
*/

#include "THIS_CLASS.h"
#include "nihclIO.h"
// #include .h files for other classes used

#define	THIS	THIS_CLASS
// Define BASE only for classes with one base class
#define	BASE	BASE_CLASS
// Define list of addresses of descriptors of all base classes:
#define	BASE_CLASSES BASE::desc()
// Define list of addresses of descriptors of all member classes:
#define	MEMBER_CLASSES
// Define list of addresses of descriptors of all virtual base classes:
#define	VIRTUAL_BASE_CLASSES

DEFINE_CLASS(THIS_CLASS,1,"$Header: Template_c,v 2.204 89/10/07 23:22:02 keith Stab $",NULL,NULL);
// For abstract classes:
//DEFINE_ABSTRACT_CLASS(THIS_CLASS,1,"$Header: Template_c,v 2.204 89/10/07 23:22:02 keith Stab $",NULL,NULL);
// For non-abstract classes with multiple base classes:
//DEFINE_CLASS_MI(THIS_CLASS,1,"$Header: Template_c,v 2.204 89/10/07 23:22:02 keith Stab $",NULL,NULL);
// For abstract classes with multiple base classes:
//DEFINE_ABSTRACT_CLASS_MI(THIS_CLASS,1,"$Header: Template_c,v 2.204 89/10/07 23:22:02 keith Stab $",NULL,NULL);

extern const int // error codes

/* _castdown() for classes with multiple base classes:

void* THIS_CLASS::_castdown(const Class& target) const
// (Probably a good candidate for memoization.)
{
	if (&target == desc()) return (void*)this;
	void* p = BASE1::_castdown(target);
	void* q = p;
	if (p = BASE2::_castdown(target)) ambigCheck(p,q,target);
// ...
	if (p = BASEn::_castdown(target)) ambigCheck(p,q,target);
	return q;
}

*/

bool THIS_CLASS::operator==(const THIS_CLASS& a) const
// Test two instances of THIS_CLASS for equality
{
}

const Class* THIS_CLASS::species() const
// Return a pointer to the descriptor of the species of this class
{
	return &classDesc;
}

bool THIS_CLASS::isEqual(const Object& p) const
// Test two objects for equality
{
	return p.isSpecies(classDesc) && *this==castdown(p);
}

unsigned THIS_CLASS::hash() const
// If two objects are equal (i.e., isEqual) they must have the same hash
{
}

int THIS_CLASS::compare(const Object& p) const
// Compare two objects.  If *this > p return >0, *this == p return 0, and
// if *this < p return <0.
{
	assertArgSpecies(p,classDesc,"compare");
}

void THIS_CLASS::deepenShallowCopy()
// Called by deepCopy() to convert a shallow copy to a deep copy.
// deepCopy() makes the shallow copy by calling the copy constructor.
{
/*
Deepen base classes in order specified in class declaration.

Deepen virtual base classes (VBase):
	VBase::deepenVBase();		// do not do this for class Object

Deepen non-virtual base classes (BASE):
	BASE::deepenShallowCopy();	// do not do this for class Object

Nothing need be done for member variables that are fundamental types.
Copy a member variable o that is an NIHCL object:
	o.deepenShallowCopy();

Copy a member variable p that is a pointer to an NIHCL object of class
CLASS:
	p = (CLASS*)p->deepCopy();
*/
}

void THIS_CLASS::printOn(ostream& strm) const
// Print this object on an ostream
{
}

// Object I/O

/*
Member class instances are constructed in the order they are declared
in the class declaration, regardless of the order they appear in the
constructor initialization list, so they must be stored in this order.
Note that member class instances are constructed before body of
constructor is executed.
*/

// Construct an object from OIOin "strm".
THIS_CLASS::THIS_CLASS(OIOin& strm)
:
#ifdef MI
	Object(strm),
#endif
/*
Call readFrom() constructors of all ancestor virtual base classes:
	VBase(strm),
*/
	BASE(strm)
/*
Read a member variable o that is an instance of an NIHCL class:
	o(strm)
{
Read a member variable f that is a fundamental type using ">>":
	strm >> f;

Read a member variable p that is a pointer to an instance of the NIHCL
class CLASS:
	p = CLASS::readFrom(strm);

Read member variables in the same order that they are stored.
*/
}

void THIS_CLASS::storer(OIOout& strm) const
// Store the member variables of this object on OIOout "strm".
{
/*
Store virtual base classes (VBase) in inheritance DAG order:
	VBase::storeVBaseOn(strm);

Store non-virtual base classes in order specified in class declaration:
	BASE::storer(strm);

Store a member variable f that is a fundamental type using "<<":
	strm << f;

Store a member variable o that is an instance of the NIHCL class
CLASS:
	o.storeMemberOn(strm);

Store a member variable p that is a pointer to an instance of an NIHCL
class:
	p->storeOn(strm);

Store member variables in the same order that they are read.
*/
}

// Construct an object from file descriptor "fd".
THIS_CLASS::THIS_CLASS(OIOifd& fd)
:
#ifdef MI
	Object(fd),
#endif
/*
Call readFrom() constructors of all ancestor virtual base classes:
	VBase(fd),
*/
	BASE(fd)
/*
Read a member variable o that is an instance of an NIHCL class:
	o(fd)
{
Read a member variable f that is a fundamental type:
	fd >> f;

Read a member variable a that is a pointer to an array of length l:
	fd.get(a,l);

Read a member variable p that is a pointer to an instance of the NIHCL
class CLASS:
	p = CLASS::readFrom(fd);

Read member variables in the same order that they are stored.
*/
}

void THIS_CLASS::storer(OIOofd& fd) const
// Store an object on file descriptor "fd".
{
/*
Store virtual base classes (VBase) in inheritance DAG order:
	VBase::storeVBaseOn(fd);

Store non-virtual base classes in order specified in class declaration:
	BASE::storer(fd);

Store a member variable f that is a fundamental type:
	fd << f;

Store a member variable a that is a pointer to an array of length l:
	fd.put(a,l);

Store a member variable o that is an instance of the NIHCL class
CLASS:
	o.storeMemberOn(fd);

Store a member variable p that is a pointer to an instance of an NIHCL
class:
	p->storeOn(fd);

Store member variables in the same order that they are read.
*/
}
