Archival snapshot of the Virtual World Entertainment Tesla cockpit software, 1994-1996: MUNGA engine and L4 pod layer source (Borland C++ 5.0), BT/RP game code, and game content (models, audio, maps, gauges, Division renderer data). Includes third-party libraries: Division dVS/DPL graphics, HMI SOS audio, WATTCP networking. Files are preserved byte-for-byte (.gitattributes disables all line-ending conversion). README.md documents the layout, target hardware, and toolchain. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
368 lines
10 KiB
C++
368 lines
10 KiB
C++
//===========================================================================//
|
|
// File: chain.hh //
|
|
// Project: MUNGA Brick: Connection Engine //
|
|
// Contents: Interface specification of Chains and their iterators //
|
|
//---------------------------------------------------------------------------//
|
|
// Date Who Modification //
|
|
// -------- --- ---------------------------------------------------------- //
|
|
// 09/29/94 ECH Initial coding. //
|
|
// 10/20/94 JMA Fixed style stuff. Merged with CHNITR.HPP, and added //
|
|
// operator functions to iterator //
|
|
// 10/23/94 ECH Added greater deletion safety //
|
|
// 10/28/94 JMA Made compatible with SGI CC //
|
|
// 11/03/94 ECH Made compatible with BC4.0 //
|
|
// 12/12/94 ECH Changed release handling //
|
|
//---------------------------------------------------------------------------//
|
|
// Copyright (C) 1994-1995, Virtual World Entertainment, Inc. //
|
|
// PROPRIETARY AND CONFIDENTIAL //
|
|
//===========================================================================//
|
|
|
|
#if !defined(CHAIN_HPP)
|
|
# define CHAIN_HPP
|
|
|
|
# if !defined(NODE_HPP)
|
|
# include <node.hpp>
|
|
# endif
|
|
|
|
# if !defined(MEMBLOCK_HPP)
|
|
# include <memblock.hpp>
|
|
# endif
|
|
|
|
class Chain;
|
|
class ChainIterator;
|
|
|
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ChainLink ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
#define CHAINLINK_MEMORYBLOCK_ALLOCATION (100)
|
|
|
|
class ChainLink : public Link
|
|
{
|
|
friend class Chain;
|
|
friend class ChainIterator;
|
|
|
|
public:
|
|
~ChainLink();
|
|
Logical
|
|
TestInstance() const;
|
|
|
|
private:
|
|
ChainLink(
|
|
Chain *chain,
|
|
Plug *plug,
|
|
ChainLink *nextChainLink,
|
|
ChainLink *prevChainLink
|
|
);
|
|
|
|
ChainLink
|
|
*nextChainLink,
|
|
*prevChainLink;
|
|
|
|
private:
|
|
static MemoryBlock
|
|
AllocatedMemory;
|
|
|
|
void*
|
|
operator new(size_t)
|
|
{return AllocatedMemory.New();}
|
|
void
|
|
operator delete(void *where)
|
|
{AllocatedMemory.Delete(where);}
|
|
};
|
|
|
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Chain ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
class Chain:
|
|
public Socket
|
|
{
|
|
friend class ChainLink;
|
|
friend class ChainIterator;
|
|
|
|
public:
|
|
//
|
|
//--------------------------------------------------------------------
|
|
//--------------------------------------------------------------------
|
|
// Public interface
|
|
//--------------------------------------------------------------------
|
|
//--------------------------------------------------------------------
|
|
//
|
|
|
|
//
|
|
//--------------------------------------------------------------------
|
|
// Constructor, Destructor and testing
|
|
//--------------------------------------------------------------------
|
|
//
|
|
Chain(Node *node);
|
|
~Chain();
|
|
|
|
Logical
|
|
TestInstance() const;
|
|
static Logical
|
|
TestClass();
|
|
static Logical
|
|
ProfileClass();
|
|
|
|
protected:
|
|
//
|
|
//--------------------------------------------------------------------
|
|
//--------------------------------------------------------------------
|
|
// Protected interface
|
|
//--------------------------------------------------------------------
|
|
//--------------------------------------------------------------------
|
|
//
|
|
void
|
|
AddImplementation(Plug *plug);
|
|
|
|
private:
|
|
//
|
|
//--------------------------------------------------------------------
|
|
// Private methods
|
|
//--------------------------------------------------------------------
|
|
//
|
|
ChainLink*
|
|
InsertChainLink(
|
|
Plug *plug,
|
|
ChainLink *current_link
|
|
);
|
|
|
|
//
|
|
//--------------------------------------------------------------------
|
|
// Private data
|
|
//--------------------------------------------------------------------
|
|
//
|
|
ChainLink
|
|
*head,
|
|
*tail;
|
|
};
|
|
|
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ChainOf ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
template <class T> class ChainOf:
|
|
public Chain
|
|
{
|
|
public:
|
|
//
|
|
//--------------------------------------------------------------------
|
|
//--------------------------------------------------------------------
|
|
// Public interface
|
|
//--------------------------------------------------------------------
|
|
//--------------------------------------------------------------------
|
|
//
|
|
ChainOf(Node *node);
|
|
~ChainOf();
|
|
|
|
//
|
|
//--------------------------------------------------------------------
|
|
// Socket methods (see Socket for full listing)
|
|
//--------------------------------------------------------------------
|
|
//
|
|
void
|
|
Add(T plug)
|
|
{AddImplementation(Cast_Object(Plug*,plug));}
|
|
};
|
|
|
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~ ChainOf templates ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
template <class T>
|
|
ChainOf<T>::ChainOf(Node *node):
|
|
Chain(node)
|
|
{
|
|
}
|
|
|
|
template <class T>
|
|
ChainOf<T>::~ChainOf()
|
|
{
|
|
}
|
|
|
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~ ChainIterator ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
class ChainIterator:
|
|
public SocketIterator
|
|
{
|
|
public:
|
|
//
|
|
//--------------------------------------------------------------------
|
|
//--------------------------------------------------------------------
|
|
// Public interface
|
|
//--------------------------------------------------------------------
|
|
//--------------------------------------------------------------------
|
|
//
|
|
|
|
//
|
|
//--------------------------------------------------------------------
|
|
// Constructors, Destructor and testing
|
|
//--------------------------------------------------------------------
|
|
//
|
|
ChainIterator(Chain *chain);
|
|
ChainIterator(const ChainIterator &iterator);
|
|
~ChainIterator();
|
|
|
|
Logical
|
|
TestInstance() const;
|
|
|
|
//
|
|
//--------------------------------------------------------------------
|
|
// Iterator methods (see Iterator for full listing)
|
|
//--------------------------------------------------------------------
|
|
//
|
|
void
|
|
First();
|
|
void
|
|
Last();
|
|
void
|
|
Next();
|
|
void
|
|
Previous();
|
|
CollectionSize
|
|
GetSize();
|
|
void
|
|
Remove();
|
|
|
|
protected:
|
|
//
|
|
//--------------------------------------------------------------------
|
|
//--------------------------------------------------------------------
|
|
// Protected interface
|
|
//--------------------------------------------------------------------
|
|
//--------------------------------------------------------------------
|
|
//
|
|
void*
|
|
ReadAndNextImplementation();
|
|
void*
|
|
ReadAndPreviousImplementation();
|
|
void*
|
|
GetCurrentImplementation();
|
|
void*
|
|
GetNthImplementation(CollectionSize index);
|
|
void
|
|
InsertImplementation(Plug*);
|
|
|
|
//
|
|
//--------------------------------------------------------------------
|
|
//--------------------------------------------------------------------
|
|
// Protected data
|
|
//--------------------------------------------------------------------
|
|
//--------------------------------------------------------------------
|
|
//
|
|
ChainLink
|
|
*currentLink;
|
|
};
|
|
|
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~ ChainIteratorOf ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
template <class T> class ChainIteratorOf:
|
|
public ChainIterator
|
|
{
|
|
public:
|
|
//
|
|
//--------------------------------------------------------------------
|
|
//--------------------------------------------------------------------
|
|
// Public interface
|
|
//--------------------------------------------------------------------
|
|
//--------------------------------------------------------------------
|
|
//
|
|
|
|
//
|
|
//--------------------------------------------------------------------
|
|
// Constructors and Destructor
|
|
//--------------------------------------------------------------------
|
|
//
|
|
ChainIteratorOf(ChainOf<T> *chain);
|
|
ChainIteratorOf(ChainOf<T> &chain);
|
|
ChainIteratorOf(const ChainIteratorOf<T> &iterator);
|
|
~ChainIteratorOf();
|
|
|
|
//
|
|
//--------------------------------------------------------------------
|
|
// Iterator methods (see Iterator for full listing)
|
|
//--------------------------------------------------------------------
|
|
//
|
|
T
|
|
ReadAndNext()
|
|
{return (T)ReadAndNextImplementation();}
|
|
T
|
|
ReadAndPrevious()
|
|
{return (T)ReadAndPreviousImplementation();}
|
|
T
|
|
GetCurrent()
|
|
{return (T)GetCurrentImplementation();}
|
|
T
|
|
GetNth(CollectionSize index)
|
|
{return (T)GetNthImplementation(index);}
|
|
void
|
|
Insert(T plug)
|
|
{InsertImplementation(Cast_Object(Plug*,plug));}
|
|
|
|
ChainIteratorOf<T>&
|
|
Begin()
|
|
{return (ChainIteratorOf<T>&)BeginImplementation();}
|
|
ChainIteratorOf<T>&
|
|
End()
|
|
{return (ChainIteratorOf<T>&)EndImplementation();}
|
|
ChainIteratorOf<T>&
|
|
Forward()
|
|
{return (ChainIteratorOf<T>&)ForwardImplementation();}
|
|
ChainIteratorOf<T>&
|
|
Backward()
|
|
{return (ChainIteratorOf<T>&)BackwardImplementation();}
|
|
|
|
//
|
|
//---------------------------------------------------
|
|
// Operators useful when it is know that the iterator
|
|
// is a ChainOf<> Iterator
|
|
//---------------------------------------------------
|
|
//
|
|
#if 0
|
|
Logical
|
|
operator!()
|
|
{return currentLink == NULL;}
|
|
operator T*()
|
|
{return GetCurrent();}
|
|
T*
|
|
operator->()
|
|
{return GetCurrent();}
|
|
T&
|
|
operator*()
|
|
{return *GetCurrent();}
|
|
|
|
ChainIteratorOf<T>&
|
|
operator++()
|
|
{Next(); return *this;}
|
|
ChainIteratorOf<T>&
|
|
operator--()
|
|
{Previous(); return *this;}
|
|
T*
|
|
operator++(int)
|
|
{return ReadAndNext();}
|
|
T*
|
|
operator--(int)
|
|
{return ReadAndPrevious();}
|
|
#endif
|
|
};
|
|
|
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~ ChainIteratorOf templates ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
template <class T>
|
|
ChainIteratorOf<T>::ChainIteratorOf(ChainOf<T> *chain):
|
|
ChainIterator(chain)
|
|
{
|
|
}
|
|
|
|
template <class T>
|
|
ChainIteratorOf<T>::ChainIteratorOf(ChainOf<T> &chain):
|
|
ChainIterator(&chain)
|
|
{
|
|
}
|
|
|
|
template <class T>
|
|
ChainIteratorOf<T>::ChainIteratorOf(const ChainIteratorOf<T> &iterator):
|
|
ChainIterator(iterator)
|
|
{
|
|
}
|
|
|
|
template <class T>
|
|
ChainIteratorOf<T>::~ChainIteratorOf()
|
|
{
|
|
}
|
|
|
|
#endif
|