MyCaffe  1.12.2.41
Deep learning software for Windows C# programmers.
ParameterDescriptorCollection.cs
1using System;
2using System.Collections;
3using System.Collections.Generic;
4using System.Linq;
5using System.Text;
6using System.Threading.Tasks;
7
9{
13 [Serializable]
14 public class ParameterDescriptorCollection : IEnumerable<ParameterDescriptor>
15 {
16 List<ParameterDescriptor> m_rgParams = new List<ParameterDescriptor>();
17 Dictionary<string, int> m_rgParamIdx = new Dictionary<string, int>();
18
23 {
24 }
25
31 {
32 foreach (ParameterDescriptor p in rg)
33 {
34 m_rgParamIdx.Add(p.Name, m_rgParams.Count);
35 m_rgParams.Add(p.Clone());
36 }
37 }
38
42 public int Count
43 {
44 get { return m_rgParams.Count; }
45 }
46
52 public ParameterDescriptor this[int nIdx]
53 {
54 get { return m_rgParams[nIdx]; }
55 }
56
61 public void Add(ParameterDescriptor p)
62 {
63 m_rgParamIdx.Add(p.Name, m_rgParams.Count);
64 m_rgParams.Add(p);
65 }
66
72 public ParameterDescriptor Find(string strName)
73 {
74 if (!m_rgParamIdx.ContainsKey(strName))
75 return null;
76
77 int nIdx = m_rgParamIdx[strName];
78 return m_rgParams[nIdx];
79 }
80
87 public string Find(string strName, string strDefault)
88 {
89 ParameterDescriptor p = Find(strName);
90 if (p == null)
91 return strDefault;
92
93 return p.Value;
94 }
95
102 public double Find(string strName, double dfDefault)
103 {
104 string strVal = Find(strName, null);
105 if (strVal == null)
106 return dfDefault;
107
108 return BaseParameter.ParseDouble(strVal);
109 }
110
117 public bool Find(string strName, bool bDefault)
118 {
119 string strVal = Find(strName, null);
120 if (strVal == null)
121 return bDefault;
122
123 return bool.Parse(strVal);
124 }
125
130 public IEnumerator<ParameterDescriptor> GetEnumerator()
131 {
132 return m_rgParams.GetEnumerator();
133 }
134
139 IEnumerator IEnumerable.GetEnumerator()
140 {
141 return m_rgParams.GetEnumerator();
142 }
143 }
144}
The BaseParameter class is the base class for all other parameter classes.
static double ParseDouble(string strVal)
Parse double values using the US culture if the decimal separator = '.', then using the native cultur...
The ParameterDescriptorCollection class contains a list of ParameterDescriptor's.
ParameterDescriptorCollection(ParameterDescriptorCollection rg)
The ParameterDescriptorCollection constructor.
bool Find(string strName, bool bDefault)
Searches for a parameter by name and returns its value as a bool if found, or a default bool value if...
int Count
Returns the count of items in the collection.
double Find(string strName, double dfDefault)
Searches for a parameter by name and returns its value as a double if found, or a default double valu...
IEnumerator< ParameterDescriptor > GetEnumerator()
Returns the enumerator of the collection.
void Add(ParameterDescriptor p)
Adds a ParameterDescriptor to the collection.
ParameterDescriptor Find(string strName)
Searches for a parameter by name in the collection.
ParameterDescriptorCollection()
The ParameterDescriptorCollection constructor.
string Find(string strName, string strDefault)
Searches for a parameter by name and returns its string value if found, or a default string value if ...
The ParameterDescriptor class describes a parameter in the database.
virtual ParameterDescriptor Clone()
Creates a copy of the parameter descriptor.
string Value
Get/set the value of the item.
The descriptors namespace contains all descriptor used to describe various items stored within the da...