📄 decisiontable.cpp
字号:
int unmasked;
if (masked)
unmasked = GetUnmaskedAttribute(attribute_no);
else
unmasked = attribute_no;
return GetDictionary()->GetAttribute(unmasked)->SetName(name);
}
//-------------------------------------------------------------------
// Method........: GetAttributeUnit
// Author........: Aleksander 豩rn
// Date..........:
// Description...:
// Comments......:
// Revisions.....:
//===================================================================
const String &
DecisionTable::GetAttributeUnit(int attribute_no, bool masked) const {
// Static so we can return a reference.
static String dummy = "";
// Dictionary present?
if (!HasDictionary())
return dummy;
int unmasked;
if (masked)
unmasked = GetUnmaskedAttribute(attribute_no);
else
unmasked = attribute_no;
return GetDictionary()->GetAttribute(unmasked)->GetUnit();
}
//-------------------------------------------------------------------
// Method........: SetAttributeUnit
// Author........: Aleksander 豩rn
// Date..........:
// Description...:
// Comments......:
// Revisions.....:
//===================================================================
bool
DecisionTable::SetAttributeUnit(int attribute_no, const String &unit, bool masked) {
// No dictionary present.
if (!HasDictionary())
return false;
int unmasked;
if (masked)
unmasked = GetUnmaskedAttribute(attribute_no);
else
unmasked = attribute_no;
return GetDictionary()->GetAttribute(unmasked)->SetUnit(unit);
}
//-------------------------------------------------------------------
// Method........: GetAttributeScalingExponent
// Author........: Aleksander 豩rn
// Date..........:
// Description...:
// Comments......:
// Revisions.....:
//===================================================================
int
DecisionTable::GetAttributeScalingExponent(int attribute_no, bool masked) const {
// Dictionary present?
if (!HasDictionary())
return 0;
int unmasked;
if (masked)
unmasked = GetUnmaskedAttribute(attribute_no);
else
unmasked = attribute_no;
return GetDictionary()->GetAttribute(unmasked)->GetScalingExponent();
}
//-------------------------------------------------------------------
// Method........: SetAttributeScalingExponent
// Author........: Aleksander 豩rn
// Date..........:
// Description...:
// Comments......:
// Revisions.....:
//===================================================================
bool
DecisionTable::SetAttributeScalingExponent(int attribute_no, int exponent, bool masked) {
// No dictionary present.
if (!HasDictionary())
return false;
int unmasked;
if (masked)
unmasked = GetUnmaskedAttribute(attribute_no);
else
unmasked = attribute_no;
return GetDictionary()->GetAttribute(unmasked)->SetScalingExponent(exponent);
}
//-------------------------------------------------------------------
// Method........: GetAttributeType
// Author........: Aleksander 豩rn
// Date..........:
// Description...:
// Comments......:
// Revisions.....:
//===================================================================
Attribute::Type
DecisionTable::GetAttributeType(int attribute_no, bool masked) const {
// No dictionary present.
if (!HasDictionary())
return Attribute::TYPE_INTEGER;
int unmasked;
if (masked)
unmasked = GetUnmaskedAttribute(attribute_no);
else
unmasked = attribute_no;
return GetDictionary()->GetAttribute(unmasked)->GetType();
}
//-------------------------------------------------------------------
// Method........: GetAttributeIndex
// Author........: Aleksander 豩rn
// Date..........:
// Description...: Returns the index of the named attribute.
// If names are non-unique, returns the first match
// found.
// Comments......:
// Revisions.....:
//===================================================================
int
DecisionTable::GetAttributeIndex(const String &attribute_name, bool case_sensitive, bool masked) const {
int attribute_no, no_attributes = GetNoAttributes(masked);
// Define a mutable copy.
String tmp = attribute_name;
if (!case_sensitive)
tmp.ToLowercase();
// Scan through all attributes.
for (attribute_no = 0; attribute_no < no_attributes; attribute_no++) {
String name = GetAttributeName(attribute_no, masked);
if (!case_sensitive)
name.ToLowercase();
if (name == tmp)
return attribute_no;
}
// No match.
return Undefined::Integer();
}
//-------------------------------------------------------------------
// Method........: IsNumeric
// Author........: Aleksander 豩rn
// Date..........:
// Description...:
// Comments......:
// Revisions.....:
//===================================================================
bool
DecisionTable::IsNumeric(int attribute_no, bool masked) const {
// No dictionary present.
if (!HasDictionary())
return true;
int unmasked;
if (masked)
unmasked = GetUnmaskedAttribute(attribute_no);
else
unmasked = attribute_no;
return GetDictionary()->GetAttribute(unmasked)->IsNumeric();
}
//-------------------------------------------------------------------
// Method........: IsNumeric
// Author........: Aleksander 豩rn
// Date..........:
// Description...:
// Comments......:
// Revisions.....:
//===================================================================
bool
DecisionTable::IsSymbolic(int attribute_no, bool masked) const {
return !IsNumeric(attribute_no, masked);
}
//-------------------------------------------------------------------
// Method........: IsInteger
// Author........: Aleksander 豩rn
// Date..........:
// Description...:
// Comments......:
// Revisions.....:
//===================================================================
bool
DecisionTable::IsInteger(int attribute_no, bool masked) const {
// No dictionary present.
if (!HasDictionary())
return true;
int unmasked;
if (masked)
unmasked = GetUnmaskedAttribute(attribute_no);
else
unmasked = attribute_no;
return GetDictionary()->GetAttribute(unmasked)->IsInteger();
}
//-------------------------------------------------------------------
// Method........: IsFloat
// Author........: Aleksander 豩rn
// Date..........:
// Description...:
// Comments......:
// Revisions.....:
//===================================================================
bool
DecisionTable::IsFloat(int attribute_no, bool masked) const {
// No dictionary present.
if (!HasDictionary())
return false;
int unmasked;
if (masked)
unmasked = GetUnmaskedAttribute(attribute_no);
else
unmasked = attribute_no;
return GetDictionary()->GetAttribute(unmasked)->IsFloat();
}
//-------------------------------------------------------------------
// Method........: IsInteger
// Author........: Aleksander 豩rn
// Date..........:
// Description...:
// Comments......:
// Revisions.....:
//===================================================================
bool
DecisionTable::IsString(int attribute_no, bool masked) const {
// No dictionary present.
if (!HasDictionary())
return false;
int unmasked;
if (masked)
unmasked = GetUnmaskedAttribute(attribute_no);
else
unmasked = attribute_no;
return GetDictionary()->GetAttribute(unmasked)->IsString();
}
//-------------------------------------------------------------------
// Method........: GetDictionaryEntry
// Author........: Aleksander 豩rn
// Date..........:
// Description...:
// Comments......:
// Revisions.....:
//===================================================================
int
DecisionTable::GetDictionaryEntry(int attribute_no, const String &text, bool masked) const {
// No dictionary present.
if (!HasDictionary()) {
if (text.IsInteger())
return text.GetInteger();
else
return Undefined::Integer();
}
int unmasked;
if (masked)
unmasked = GetUnmaskedAttribute(attribute_no);
else
unmasked = attribute_no;
return GetDictionary()->GetAttribute(unmasked)->GetEntry(text);
}
//-------------------------------------------------------------------
// Method........: GetDictionaryEntry
// Author........: Aleksander 豩rn
// Date..........:
// Description...:
// Comments......:
// Revisions.....:
//===================================================================
const String &
DecisionTable::GetDictionaryEntry(int attribute_no, int value, bool masked) const {
// Static so we can return a reference.
static String dummy;
// No dictionary present.
if (!HasDictionary()) {
dummy = String::Format(value);
return dummy;
}
int unmasked;
if (masked)
unmasked = GetUnmaskedAttribute(attribute_no);
else
unmasked = attribute_no;
return GetDictionary()->GetAttribute(unmasked)->GetEntry(value);
}
//-------------------------------------------------------------------
// Method........: SuggestDictionaryEntry
// Author........: Aleksander 豩rn
// Date..........:
// Description...:
// Comments......:
// Revisions.....:
//===================================================================
int
DecisionTable::SuggestDictionaryEntry(int attribute_no, const String &text, bool masked) const {
// No dictionary present.
if (!HasDictionary()) {
if (text.IsInteger())
return text.GetInteger();
else
return Undefined::Integer();
}
int unmasked;
if (masked)
unmasked = GetUnmaskedAttribute(attribute_no);
else
unmasked = attribute_no;
return GetDictionary()->SuggestEntry(unmasked, text);
}
//-------------------------------------------------------------------
// Method........: SetDictionaryEntry
// Author........: Aleksander 豩rn
// Date..........:
// Description...:
// Comments......:
// Revisions.....:
//===================================================================
bool
DecisionTable::SetDictionaryEntry(int attribute_no, int value, const String &text, bool masked) {
// No dictionary present.
if (!HasDictionary())
return false;
int unmasked;
if (masked)
unmasked = GetUnmaskedAttribute(attribute_no);
else
unmasked = attribute_no;
return GetDictionary()->GetAttribute(unmasked)->SetEntry(value, text);
}
//-------------------------------------------------------------------
// Method........: GetNoDictionaryEntries
// Author........: Aleksander 豩rn
// Date..........:
// Description...:
// Comments......: Note that this method does not return the number of
// distinct entries that actually are in the table, but
// the number of possible values that the attribute
// might undertake, as governed by the dictionary.
// Revisions.....:
//===================================================================
int
DecisionTable::GetNoDictionaryEntries(int attribute_no, bool masked) const {
// No dictionary present.
if (!HasDictionary())
return 0;
int unmasked;
if (masked)
unmasked = GetUnmaskedAttribute(attribute_no);
else
unmasked = attribute_no;
return GetDictionary()->GetAttribute(unmasked)->GetNoEntries();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -