kidnapper.cpp
来自「粗糙集应用软件」· C++ 代码 · 共 119 行
CPP
119 行
//-------------------------------------------------------------------
// Author........: Aleksander 豩rn
// Date..........:
// Description...:
// Revisions.....:
//===================================================================
#include <stdafx.h> // Precompiled headers.
#include <copyright.h>
#include <kernel/algorithms/kidnapper.h>
#include <kernel/algorithms/keyword.h>
#include <kernel/structures/structure.h>
//-------------------------------------------------------------------
// Methods for class Kidnapper.
//===================================================================
//-------------------------------------------------------------------
// Constructors/destructor.
//===================================================================
Kidnapper::Kidnapper() {
index_ = 0;
}
Kidnapper::~Kidnapper() {
}
//-------------------------------------------------------------------
// Methods inherited from Identifier.
//===================================================================
IMPLEMENTIDMETHODS(Kidnapper, KIDNAPPER, ScriptAlgorithm)
//-------------------------------------------------------------------
// Methods inherited from Algorithm.
//===================================================================
//-------------------------------------------------------------------
// Method........: GetParameters
// Author........: Aleksander 豩rn
// Date..........:
// Description...:
// Comments......:
// Revisions.....:
//===================================================================
String
Kidnapper::GetParameters() const {
String parameters;
// Index.
parameters += Keyword::Index();
parameters += Keyword::Assignment();
parameters += String::Format(GetChildIndex());
return parameters;
}
//-------------------------------------------------------------------
// Method........: SetParameter
// Author........: Aleksander 豩rn
// Date..........:
// Description...:
// Comments......:
// Revisions.....:
//===================================================================
bool
Kidnapper::SetParameter(const String &keyword, const String &value) {
// Index.
if (keyword == Keyword::Index() && value.IsInteger())
return SetChildIndex(value.GetInteger());
return false;
}
//-------------------------------------------------------------------
// Method........: IsApplicable
// Author........: Aleksander 豩rn
// Date..........:
// Description...:
// Comments......:
// Revisions.....:
//===================================================================
bool
Kidnapper::IsApplicable(const Structure &/*structure*/, bool /*warn*/) const {
return true;
}
//-------------------------------------------------------------------
// Method........: Apply
// Author........: Aleksander 豩rn
// Date..........:
// Description...:
// Comments......:
// Revisions.....:
//===================================================================
Structure *
Kidnapper::Apply(Structure &structure) const {
// Check applicability.
if (!IsApplicable(structure))
return NULL;
// Return child.
return structure.GetChild(GetChildIndex());
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?