#include "munga.h" #pragma hdrstop #include "slot.h" #include "node.h" MemoryBlock *SlotLink::GetAllocatedMemory() { static MemoryBlock allocatedMemory(sizeof(SlotLink), SLOTLINK_MEMORYBLOCK_ALLOCATION, SLOTLINK_MEMORYBLOCK_ALLOCATION, "SlotLink"); return &allocatedMemory; } // //########################################################################### // 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; }