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

📄 booleanfunction.cpp

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

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

#include <kernel/structures/booleanfunction.h>
#include <kernel/structures/decisiontable.h>

#include <kernel/utilities/iokit.h>

#include <kernel/basic/algorithm.h>
#include <kernel/basic/set.h>
#include <kernel/basic/message.h>

#include <kernel/system/fstream.h>

#include <common/configuration.h>

//-------------------------------------------------------------------
// Methods for class BooleanFunction.
//===================================================================

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

//-------------------------------------------------------------------
// Method........: Constructor
// Author........: Aleksander 豩rn
// Date..........:
// Description...: Copy constructor
// Comments......: Does a shallow copy. Consider deep copying.
// Revisions.....:
//===================================================================

BooleanFunction::BooleanFunction(const BooleanFunction &in) : Structure(in) {

	int i;

  name_       = in.name_;
  components_ = in.components_;

	// Shallow copy, do not take ownership.
  for (i = 0; i < in.components_.size(); i++)
		components_[i].is_owner_ = false;

}

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

BooleanFunction::BooleanFunction() {
  name_ = Undefined::String();
}

//-------------------------------------------------------------------
// Method........: Destructor.
// Author........: Aleksander 豩rn
// Date..........:
// Description...:
// Comments......: Deletion of Bits not done in ~BFComponent since we
//                 then get unwanted deletions when temporaries etc. go
//                 out of scope.
// Revisions.....:
//===================================================================

BooleanFunction::~BooleanFunction() {

	int i;

  // Delete those components that it "owns".
  for (i = 0; i < components_.size(); i++) {
    if (components_[i].is_owner_)
      delete components_[i].bits_;
  }

  components_.erase(components_.begin(), components_.end());

}

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

IMPLEMENTIDMETHODS(BooleanFunction, BOOLEANFUNCTION, Structure)

//-------------------------------------------------------------------
// Methods inherited from Persistent.
//===================================================================

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

bool
BooleanFunction::Load(ifstream &stream) {
  return Load(stream, NULL, false);
}

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

bool
BooleanFunction::Save(ofstream &stream) const {
  return Save(stream, NULL, false);
}

//-------------------------------------------------------------------
// Methods inherited from Structure.
//===================================================================

//-------------------------------------------------------------------
// Method........: Clear
// Author........: Aleksander 豩rn
// Date..........:
// Description...:
// Comments......: See ~BooleanFunction comment.
// Revisions.....:
//===================================================================

void
BooleanFunction::Clear() {

	int i;

  name_ = Undefined::String();

  // Delete those components that it "owns".
  for (i = 0; i < components_.size(); i++) {
    if (components_[i].is_owner_)
      delete components_[i].bits_;
  }

  components_.erase(components_.begin(), components_.end());

}

//-------------------------------------------------------------------
// New methods.
//===================================================================

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

const String &
BooleanFunction::GetName() const {
  return name_;
}

bool
BooleanFunction::SetName(const String &name) {
  name_ = name;
  return true;
}

//-------------------------------------------------------------------
// Method........: GetArity
// Author........: Aleksander 豩rn
// Date..........:
// Description...: Returns the number of variables in the function.
//
//                 Example: f = 0x + 0y + 1z
//
//                          f.GetArity(true)  = 1
//                          f.GetArity(false) = 3
//
// Comments......: Assumes all bit sets have same length.
// Revisions.....: A

⌨️ 快捷键说明

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