📄 ladder.cpp
字号:
//
// Ladder
// A pipeline that consists of two parallel pipelines that are combined by a "Join" function.
// Any image input is passed down both pipelines and the results of each are combined in the
// join function, giving the result. Unlike a real ladder, the two pipelines do not have to
// be the same length, but they must both give exactly one result for one input. The input
// image is replicated so that both pipelines can modify it if they wish.
//
// Copyright (C) 2003, 2006 by Jon A. Webb (Contact via GMail; username is jonawebb)
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
//
#include "Ladder.h"
#include "Replicate.h"
namespace Core
{
//
// Lifecycle
//
EXPORT_C CLadder* CLadder::NewL(MPipelineStage* pPipe1, MPipelineStage* pPipe2, MJoin* pJoin) {
return new (ELeave) CLadder(pPipe1, pPipe2, pJoin);
}
CLadder::~CLadder(void) {
delete iPipe1;
delete iPipe2;
delete iJoin;
}
CLadder::CLadder(MPipelineStage* pPipe1, MPipelineStage* pPipe2, MJoin* pJoin) :
ibEmpty(true), iPipe1(pPipe1), iPipe2(pPipe2), iJoin(pJoin)
{}
//
// Overrides
//
CImage CLadder::FrontL()
{
if (ibEmpty) {
User::Leave(KErrGeneral);
return CImage();
}
ibEmpty = true;
return iResult;
}
void CLadder::PushL(CImage image) {
// make a copy of the input image for the second pipeline,
// in case either one alters it.
IReplicate rRepl(image);
rRepl.CopyL(iImage);
iPipe1->PushL(image);
iPipe2->PushL(iImage);
// make sure we can legally do the join
if (iPipe1->Empty() || iPipe2->Empty()) {
User::Leave(KErrGeneral);
}
// do the join
iResult = iJoin->DoJoinL(iPipe1->FrontL(), iPipe2->FrontL());
ibEmpty = false;
}
bool CLadder::Empty() const {
return ibEmpty;
}
};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -