Publishers of technology books, eBooks, and videos for creative people

Home > Articles > Web Design & Development > PHP/MySQL/Scripting

  • Print
  • + Share This
Like this article? We recommend

The LSP Is Created and Later Deleted Using the Command Pattern

Let’s now put it all together and describe the full workflow from creation to deletion.

Listing 8 The main() Function: Create-Delete Workflow

int main()
{
    LspConnection* lsp = new LspConnection(1, 0, 1);

    deleteNetworkObject* deleteObject = new deleteNetworkObject(lsp);
    deleteObject->Execute();

    delete lsp;
    delete deleteObject;

    return 0;
}

We create an instance of LspConnection on the first line. Next, we instantiate a command pattern object called deleteObject. We use the latter object to manipulate the instance of LspConnection. This manipulation is not too exciting, though! We just delete the object pointed to by lsp. When the deletion has occurred, we then delete the command pattern object (deleteObject) and the program ends.

Obviously, there are other operations that can be executed against objects, such as LSPs. For example, LSPs can be modified to use more bandwidth (for example, if more incoming telephony traffic arrived at R2). Another common operation is to create a backup LSP to allow for service continuity if the primary path fails. Additional command pattern classes can be written for these operations, thereby separating the class and operations code.

  • + Share This
  • 🔖 Save To Your Account