//===========================================================================// // File: slot.hh // // Project: MUNGA Brick: Connection Library // // Contents: Interface specification for slot class // //---------------------------------------------------------------------------// // Date Who Modification // // -------- --- ---------------------------------------------------------- // // 10/20/94 ECH Initial coding. // // 10/28/94 JMA Made compatible with SGI CC // // 11/03/94 ECH Made compatible with BC4.0 // // 11/05/94 JMA Made compatible with GNU C++ // // 12/12/94 ECH Changed release handling // //---------------------------------------------------------------------------// // Copyright (C) 1994-1995, Virtual World Entertainment, Inc. // // All Rights reserved worldwide // // This unpublished sourcecode is PROPRIETARY and CONFIDENTIAL // //===========================================================================// #pragma once #include "Stuff.hpp" #include "Socket.hpp" #include "MemoryBlock.hpp" namespace Stuff { class Slot; //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ SlotLink ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ class SlotLink: public Link { friend class Slot; public: static void InitializeClass(unsigned block_count); static void TerminateClass(); protected: ~SlotLink(); SlotLink( Slot *slot, Plug *plug ); private: static MemoryBlock *s_AllocatedMemory; void* operator new(size_t) {return s_AllocatedMemory->New();} void operator delete(void *where) {s_AllocatedMemory->Delete(where);} }; //~~~~~~~~~~~~~~~~~~~~~~~~~~~ Slot ~~~~~~~~~~~~~~~~~~~~~~~~~~~ class _declspec(novtable) Slot: public Socket { friend class SlotLink; public: // //-------------------------------------------------------------------- //-------------------------------------------------------------------- // Public interface //-------------------------------------------------------------------- //-------------------------------------------------------------------- // // //-------------------------------------------------------------------- // Constructor, Destructor and testing //-------------------------------------------------------------------- // explicit Slot(void *node=NULL); ~Slot(); void TestInstance(); //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Socket methods // public: // //----------------------------------------------------------------------- // DeletePlugs - For each plug in the socket, the routine unregisters it // and then deletes it. //----------------------------------------------------------------------- // void AddPlug(Plug *plug); // //----------------------------------------------------------------------- // RemovePlug - Remove a plug from this socket, untyped access. //----------------------------------------------------------------------- // void DeletePlugs(); void Remove(); // //----------------------------------------------------------------------- // IsPlugMember - Determine if the plug is a member of this socket. //----------------------------------------------------------------------- // void* GetNthItem(unsigned index); // //----------------------------------------------------------------------- // IsEmpty - Returns true if the socket contains no plugs. //----------------------------------------------------------------------- // unsigned GetSize(); bool IsEmpty(); protected: // //-------------------------------------------------------------------- //-------------------------------------------------------------------- // Protected interface //-------------------------------------------------------------------- //-------------------------------------------------------------------- // Plug* GetCurrentPlug() const; private: // //-------------------------------------------------------------------- // Private data //-------------------------------------------------------------------- // SlotLink *m_slotLink; }; //~~~~~~~~~~~~~~~~~~~~~~~~~~~ SlotOf ~~~~~~~~~~~~~~~~~~~~~~~~~~~ template class SlotOf: public Slot { public: // //-------------------------------------------------------------------- //-------------------------------------------------------------------- // Public interface //-------------------------------------------------------------------- //-------------------------------------------------------------------- // explicit SlotOf(void *node=NULL) {} // //-------------------------------------------------------------------- // Socket methods (see Socket for full listing) //-------------------------------------------------------------------- // void Add(T plug) {Slot::AddPlug(Cast_Object(Plug*,plug));} T GetCurrent() const {return (T)Slot::GetCurrentPlug();} }; }