-
Notifications
You must be signed in to change notification settings - Fork 0
/
BaseModule.cs
139 lines (121 loc) · 4.17 KB
/
BaseModule.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
/* Written by Joseph N. Brown
* for the Department of Energy (PNNL, Richland, WA)
* Battelle Memorial Institute
* E-mail: [email protected]
* Website: https://github.com/PNNL-Comp-Mass-Spec/ or https://panomics.pnnl.gov/ or https://www.pnnl.gov/integrative-omics
* -----------------------------------------------------
*
* Licensed under the 2-Clause BSD License; you may not use this
* file except in compliance with the License. You may obtain
* a copy of the License at https://opensource.org/licenses/BSD-2-Clause
* -----------------------------------------------------*/
using System;
using System.Collections.Generic;
using System.Data;
using System.Xml;
namespace Cyclops
{
public abstract class BaseModule
{
private DataModules.BaseDataModule m_ParentModule;
/// <summary>
/// Name of the module
/// </summary>
public string ModuleName { get; set; } = "";
/// <summary>
/// Description of the module
/// </summary>
public string Description { get; set; } = "";
/// <summary>
/// Parameters that can be used by the module
/// </summary>
public Dictionary<string, string> Parameters { get; set; }
/// <summary>
/// Number of the module in order supplied to Cyclops
/// </summary>
public int StepNumber { get; set; } = 0;
/// <summary>
/// Instance of the Model Class
/// </summary>
public CyclopsModel Model { get; set; }
/// <summary>
/// Runs the module's operation
/// </summary>
public virtual bool PerformOperation()
{
return true;
}
/// <summary>
/// Checks the parameters to ensure that all required keys are present
/// </summary>
/// <returns>True, if all required keys are included in the
/// Parameters</returns>
public virtual bool CheckParameters()
{
return true;
}
public virtual void WriteModuleToXML(XmlWriter Writer)
{
}
public virtual DataTable WriteModuleToDataTable(DataTable Table)
{
return Table;
}
/// <summary>
/// Indicates whether the module has a parent
/// </summary>
/// <returns>True, if module has a parent</returns>
public bool HasParent()
{
return m_ParentModule != null;
}
/// <summary>
/// Sets the parent for the module
/// </summary>
/// <param name="Parent">Parent module (must be a BaseDataModule)</param>
public void SetParent(DataModules.BaseDataModule Parent)
{
m_ParentModule = Parent;
}
/// <summary>
/// Get the parent module
/// </summary>
/// <returns>Parent module</returns>
public DataModules.BaseDataModule GetParent()
{
return m_ParentModule;
}
/// <summary>
/// Print the module's name
/// </summary>
public virtual void PrintModule()
{
Console.WriteLine(ModuleName);
}
/// <summary>
/// Returns the module's name as a string
/// </summary>
/// <returns>Module's name</returns>
public virtual string GetDescription()
{
return ModuleName;
}
/// <summary>
/// Generates a random string with the prefix "tmpTable_"
/// </summary>
/// <returns>Random temporary table name</returns>
public virtual string GetTemporaryTableName()
{
return Model.RCalls.GetTemporaryTableName();
}
/// <summary>
/// Generates a random temporary table name
/// </summary>
/// <param name="Prefix">Prefix appended to random name</param>
/// <returns>random name for a temporary table</returns>
public virtual string GetTemporaryTableName(string Prefix)
{
return Model.RCalls.GetTemporaryTableName(Prefix);
}
}
}