⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 applicator.h

📁 粗糙集应用软件
💻 H
字号:
//-------------------------------------------------------------------
// Author........: Aleksander 豩rn
// Date..........:
// Description...:
// Revisions.....:
//===================================================================

#ifndef __APPLICATOR_H__
#define __APPLICATOR_H__

#include <copyright.h>

#include <kernel/algorithms/algorithm.h>

#include <kernel/structures/structure.h>

//-------------------------------------------------------------------
// Class.........: Applicator
// Author........: Aleksander 豩rn
// Date..........:
// Description...: Applies an algorithm to a structure, using exceptions.
// Revisions.....:
//===================================================================

class Applicator {
protected:

	//- The objects....................................................
	Handle<Algorithm> algorithm_;
	Handle<Structure> structure_;

	//- Constructor....................................................
	Applicator();

public:

	//- Constructor....................................................
	Applicator(Algorithm *algorithm, Structure *structure);

	//- Application....................................................
  Structure *Apply();

};

//-------------------------------------------------------------------
// Methods for class Applicator (inlined).
//===================================================================

//-------------------------------------------------------------------
// Method........: Empty constructor
// Author........: Aleksander 豩rn
// Date..........:
// Description...:
// Comments......: Made protected in order to render it inaccessible.
// Revisions.....:
//===================================================================

inline
Applicator::Applicator() {
}

//-------------------------------------------------------------------
// Method........: Constructor
// Author........: Aleksander 豩rn
// Date..........:
// Description...:
// Comments......:
// Revisions.....:
//===================================================================

inline
Applicator::Applicator(Algorithm *algorithm, Structure *structure) {
	algorithm_ = algorithm;
	structure_ = structure;
}

//-------------------------------------------------------------------
// Method........: Apply
// Author........: Aleksander 豩rn
// Date..........:
// Description...: Applies the algorithm to the structure.  If the
//                 application fails, an exception is thrown.
// Comments......:
// Revisions.....:
//===================================================================

inline Structure *
Applicator::Apply() {

	if (algorithm_ == NULL)
		throw "Algorithm is NULL.";

	if (structure_ == NULL)
		throw "Structure is NULL.";

	Handle<Structure> result = structure_->Apply(*algorithm_);

	if (result == NULL)
		throw "Application failed.";

	return result.Release();

}

#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -