/
YakuninAV
/
Convertors
Обзор
Документация
Войти
/
YakuninAV
/
Convertors
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
Estimate/EstVariables.pas
176 строк
5 KB
YakuninAV
begin with gitflick
31 июл 2026, 15:21
31 июл 2026, 15:21
1dc0fc6
Код
Авторство
О чём код?
unit EstVariables; {$I Synopse.inc} // define HASINLINE USETYPEINFO CPU32 CPU64 OWNNORMTOUPPER interface uses SysUtils, Classes, Types, DateUtils, SynCommons, EstTypes, EstIntfsV2; type /// Класс реализующий доступ к информации о переменной TEstVariable = class(TInterfacedObject, IEstVariableV2) private FName, FFormula, FDescription: string; FValue: Extended; FFractional: Integer; function GetFractional: Integer; function GetName: string; function GetValue: Extended; function GetFormula: string; function GetDescription: string; procedure SetFractional(const NewValue: Integer); procedure SetName(const NewValue: string); procedure SetValue(const NewValue: Extended); procedure SetFormula(const NewValue: string); procedure SetDescription(const NewValue: string); public /// Наименование переменной property Name: string read GetName write SetName; /// Значение переменной property Value: Extended read GetValue write SetValue; /// Формула для вычисления значения. В формуле могут быть использованы наименования других переменных property Formula: string read GetFormula write SetFormula; /// Описание переменной property Description: string read GetDescription write SetDescription; /// Количество знаков после десятичной точки property Fractional: Integer read GetFractional write SetFractional; /// Конструктор constructor Create(const aName: string; const aValue: Extended; const aFormula: string=''; const aFractional: Integer=2; const aDescription: string=''); end; /// Класс реализующий интерфейс для работы со списком переменных TEstVariablesList = class(TInterfacedObject, IEstVariablesListV2) private FOptions: TEstListOptions; FVariables: TEstVariables; function GetOptions: TEstListOptions; function GetVariable(Name: string): IEstVariableV2; procedure SetOptions(Value: TEstListOptions); public /// Опции списка переменных property Options: TEstListOptions read GetOptions write SetOptions; /// Переменные в списке property Variable[Name: string]: IEstVariableV2 read GetVariable; /// Конструктор constructor Create(aOptions: TEstListOptions); /// Деструктор destructor Destroy; override; /// Добавляет реквизит в список. Если реквизит с именем уже в списке, то реквизит заменяется function Add(aVariable: IEstVariableV2): Integer; /// Функция возвращает количество переменных в списке function Count: Integer; end; implementation { TEstVariable } constructor TEstVariable.Create(const aName: string; const aValue: Extended; const aFormula: string; const aFractional: Integer; const aDescription: string); begin inherited Create; SetName(aName); SetValue(aValue); SetFormula(aFormula); SetFractional(aFractional); SetDescription(aDescription); end; function TEstVariable.GetDescription: string; begin Result:=FDescription; end; function TEstVariable.GetFormula: string; begin Result:=FFormula; end; function TEstVariable.GetFractional: Integer; begin Result:=FFractional; end; function TEstVariable.GetName: string; begin Result:=FName; end; function TEstVariable.GetValue: Extended; begin Result:=FValue; end; procedure TEstVariable.SetDescription(const NewValue: string); begin FDescription:=NewValue; end; procedure TEstVariable.SetFormula(const NewValue: string); begin FFormula:=NewValue; end; procedure TEstVariable.SetFractional(const NewValue: Integer); begin FFractional:=NewValue; end; procedure TEstVariable.SetName(const NewValue: string); begin FName:=NewValue; end; procedure TEstVariable.SetValue(const NewValue: Extended); begin FValue:=NewValue; end; { TEstVariablesList } function TEstVariablesList.Add(aVariable: IEstVariableV2): Integer; begin end; function TEstVariablesList.Count: Integer; begin Result:=Length(FVariables); end; constructor TEstVariablesList.Create(aOptions: TEstListOptions); begin inherited Create; SetOptions(aOptions); SetLength(FVariables,0); end; destructor TEstVariablesList.Destroy; var i: Integer; begin for i := Low(FVariables) to (High(FVariables)) do FVariables[i]:=nil; SetLength(FVariables,0); inherited; end; function TEstVariablesList.GetOptions: TEstListOptions; begin Result:=FOptions; end; function TEstVariablesList.GetVariable(Name: string): IEstVariableV2; var i: Integer; begin for i := Low(FVariables) to (High(FVariables)) do if FVariables[i].Name=Name then begin Result:=FVariables[i]; Exit; end; Result:=nil; end; procedure TEstVariablesList.SetOptions(Value: TEstListOptions); begin FOptions:=Value; end; end.