chxavcompositecommand.cpp
上传用户:zhongxx05
上传日期:2007-06-06
资源大小:33641k
文件大小:2k
源码类别:
Symbian
开发平台:
C/C++
- /************************************************************************
- * chxavcompositecommand.cpp
- * -------------------------
- *
- * Synopsis:
- *
- *
- * Implementation of aggregated command object
- *
- * commands (actions) are executed in order of addition
- * copying the command object implies sharing a reference to the aggregated list
- *
- * Target:
- * Symbian OS
- *
- *
- * (c) 1995-2003 RealNetworks, Inc. Patents pending. All rights reserved.
- *
- ************************************************************************/
- // Symbian includes...
- #include <e32std.h>
- // Include from this project...
- #include "chxavcompositecommand.h"
- CHXAvCompositeCommand::CHXAvCompositeCommand(const CHXAvCompositeCommand& rhs) :
- m_nextId(rhs.m_nextId)
- {
- // Copy the command list
- LISTPOSITION pos = rhs.m_commands.GetHeadPosition();
- while (pos != NULL)
- {
- CHXAvCommand *ptr = (CHXAvCommand *)rhs.m_commands.GetNext(pos);
- AppendL(*ptr);
- }
- }
- CHXAvCompositeCommand::~CHXAvCompositeCommand()
- {
- LISTPOSITION pos = m_commands.GetHeadPosition();
- while (pos != NULL)
- {
- CHXAvCommand *ptr = (CHXAvCommand *)m_commands.GetNext(pos);
- delete ptr;
- }
- }
- ////////////////////////////////////////
- // add an action; becomes last command to be executed
- // return id that can be used to remove command
- // later on
- //
- CHXAvCompositeCommand::CID CHXAvCompositeCommand::AppendL(const CHXAvCommand& cmd)
- {
- CHXAvCommand *pCmd = cmd.CloneL();
- m_commands.AddTail(pCmd);
- return pCmd;
- }
- ////////////////////////////////////////
- // add an action; becomes last command to be executed
- //
- void CHXAvCompositeCommand::Remove(CID idCommand)
- {
- LISTPOSITION pos = m_commands.Find(idCommand, NULL);
- if (pos != NULL)
- m_commands.RemoveAt(pos);
- delete (CHXAvCommand *)idCommand;
- }
- ////////////////////////////////////////
- // go through list of commands and execute each
- // in order they were added
- void CHXAvCompositeCommand::Execute()
- {
- LISTPOSITION pos = m_commands.GetHeadPosition();
- while (pos != NULL)
- {
- CHXAvCommand *ptr = (CHXAvCommand *)m_commands.GetNext(pos);
- if (ptr != NULL)
- ptr->Execute();
- }
- }