//===========================================================================// // File: slot.cc // // Project: MUNGA Brick: Connection Library // // Contents: Implementation details for the 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 // // 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 // //===========================================================================// #include #pragma hdrstop #if !defined(SLOT_HPP) #include #endif #if !defined(NODE_HPP) #include #endif MemoryBlock SlotLink::AllocatedMemory( sizeof(SlotLink), SLOTLINK_MEMORYBLOCK_ALLOCATION, SLOTLINK_MEMORYBLOCK_ALLOCATION, "SlotLink" ); // //########################################################################### // SlotLink //########################################################################### // SlotLink::SlotLink( Slot *slot, Plug *plug ): Link(slot, plug) { } // //########################################################################### // ~SlotLink //########################################################################### // SlotLink::~SlotLink() { Slot *slot = Cast_Object(Slot*, socket); // //------------------------------------------------- // Make sure the link is not referenced by the slot //------------------------------------------------- // Check(slot); Verify(slot->slotLink == this); slot->slotLink = NULL; // //------------------------------------------ // Remove this link from any plug references //------------------------------------------ // ReleaseFromPlug(); // //------------------------------------------------------------- // Tell the node to release this link. Note that this link // is not referenced by the plug or the slot at this point in // time. //------------------------------------------------------------- // if (slot->GetReleaseNode() != NULL) { Check(slot->GetReleaseNode()); slot->GetReleaseNode()->ReleaseLinkHandler(slot, plug); } } // //########################################################################### // TestInstance //########################################################################### // Logical SlotLink::TestInstance() const { Link::TestInstance(); return True; } // //########################################################################### // Slot //########################################################################### // Slot::Slot( Node *node ): Socket(node) { slotLink = NULL; } // //########################################################################### // ~Slot //########################################################################### // Slot::~Slot() { SetReleaseNode(NULL); if (slotLink != NULL) { Unregister_Object(slotLink); delete slotLink; } } // //########################################################################### // TestInstance //########################################################################### // Logical Slot::TestInstance() const { Socket::TestInstance(); if (slotLink != NULL) { Check(slotLink); } return True; } // //########################################################################### // Remove //########################################################################### // void Slot::Remove() { if (slotLink != NULL) { Unregister_Object(slotLink); delete slotLink; slotLink = NULL; } } // //########################################################################### // AddImplementation //########################################################################### // void Slot::AddImplementation( Plug *plug ) { Verify(slotLink == NULL); slotLink = new SlotLink(this, plug); Register_Object(slotLink); } // //########################################################################### // GetCurrentPlug //########################################################################### // Plug* Slot::GetCurrentPlug() const { if (slotLink != NULL) { Check(slotLink); return slotLink->GetPlug(); } return NULL; }