myreductexporter.cpp

来自「粗糙集应用软件」· C++ 代码 · 共 106 行

CPP
106
字号
//-------------------------------------------------------------------
// Author........: Aleksander 豩rn
// Date..........:
// Description...:
// Revisions.....:
//===================================================================

#include <stdafx.h> // Precompiled headers.
#include <copyright.h>

#include <kernel/algorithms/myreductexporter.h>

#include <kernel/structures/reducts.h>
#include <kernel/structures/reduct.h>

#include <kernel/utilities/systemkit.h>

#include <kernel/system/fstream.h>

//-------------------------------------------------------------------
// Methods for class MyReductExporter.
//===================================================================

//-------------------------------------------------------------------
// Constructors/destructor.
//===================================================================

MyReductExporter::MyReductExporter() {
}

MyReductExporter::~MyReductExporter() {
}

//-------------------------------------------------------------------
// Methods inherited from Identifier.
//===================================================================

IMPLEMENTIDMETHODS(MyReductExporter, MYREDUCTEXPORTER, ReductExporter)

//-------------------------------------------------------------------
// Methods inherited from Exporter.
//===================================================================

//-------------------------------------------------------------------
// Method........: ExportPrologue
// Author........: Aleksander 豩rn
// Date..........:
// Description...:
// Comments......: Consider using IOKit instead.
// Revisions.....:
//===================================================================

bool
MyReductExporter::ExportPrologue(ofstream &stream, const Structure &structure) const {

	// Cast to already verified type (in Apply method).
	Handle<Reducts> reducts = dynamic_cast(Reducts *, const_cast(Structure *, &structure));

	// Write some general information.
	stream << "% Reducts generated by ROSETTA." << endl;
	stream << "% Exported " << SystemKit::GetTimestamp() << " by " << SystemKit::GetUser() << "." << endl;
	stream << "%" << endl;
	stream << "% " << reducts->GetName() << endl;
	stream << "% " << reducts->GetNoReducts() << " reducts." << endl;
	stream << endl;

	return true;

}

//-------------------------------------------------------------------
// Methods inherited from ReductExporter.
//===================================================================

//-------------------------------------------------------------------
// Method........: ExportReduct
// Author........: Aleksander 豩rn
// Date..........:
// Description...: Overloaded to deal with this syntax.
// Comments......:
// Revisions.....:
//===================================================================

bool
MyReductExporter::ExportReduct(ofstream &stream, int /*reduct_no*/, const Reduct &reduct) const {

	String formatted;

	bool masked = true;

	// Format reduct.
	if (!reduct.Format(formatted, GetDecisionTable(), masked)) {
		Message::Error("Error formatting reduct.");
		return false;
	}

	// Dump formatted reduct to file stream.
	stream << formatted << endl;

	// Dump support to file stream.
	stream << "Support = [" << reduct.GetSupport() << " subtable(s)]" << endl << endl;

	return true;

}

⌨️ 快捷键说明

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