Skip to content

Commit 2b39178

Browse files
committed
Core: Finder refactoring to support start of ReverseChordFinder, issue #91
1 parent b75feed commit 2b39178

15 files changed

+528
-109
lines changed

Diff for: Chordious.Core/ChordFinding/ChordFinderOptions.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
namespace Chordious.Core
3030
{
31-
public class ChordFinderOptions : FinderOptions, IChordFinderOptions
31+
public class ChordFinderOptions : FinderOptions2, IChordFinderOptions
3232
{
3333
public IChordQuality ChordQuality
3434
{

Diff for: Chordious.Core/ChordFinding/IChordFinderOptions.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
namespace Chordious.Core
2828
{
29-
public interface IChordFinderOptions : IFinderOptions
29+
public interface IChordFinderOptions : IFinderOptions2
3030
{
3131
IChordQuality ChordQuality { get; }
3232
bool AllowRootlessChords { get; }

Diff for: Chordious.Core/Chordious.Core.csproj

+8
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,13 @@
4747
<ItemGroup>
4848
<Compile Include="ChordFinding\IChordFinderResult.cs" />
4949
<Compile Include="ChordFinding\IChordFinderOptions.cs" />
50+
<Compile Include="Common\Finding\FinderOptions2.cs" />
51+
<Compile Include="Common\Finding\IFinderOptions2.cs" />
52+
<Compile Include="ReverseChordFinder\ReverseChordFinderOptions.cs" />
53+
<Compile Include="ReverseChordFinder\ReverseChordFinderResult.cs" />
54+
<Compile Include="ReverseChordFinder\IReverseChordFinderOptions.cs" />
55+
<Compile Include="ReverseChordFinder\IReverseChordFinderResult.cs" />
56+
<Compile Include="ReverseChordFinder\ReverseChordFinder.cs" />
5057
<Compile Include="Common\EnumUtils.cs" />
5158
<Compile Include="Common\Finding\FinderOptions.cs" />
5259
<Compile Include="Common\Finding\IFinderOptions.cs" />
@@ -114,6 +121,7 @@
114121
<DesignTime>True</DesignTime>
115122
<DependentUpon>Strings.resx</DependentUpon>
116123
</Compile>
124+
<Compile Include="ReverseChordFinder\ReverseChordFinderResultSet.cs" />
117125
<Compile Include="ScaleFinding\IScaleFinderResult.cs" />
118126
<Compile Include="ScaleFinding\IScaleFinderOptions.cs" />
119127
<Compile Include="ScaleFinding\ScaleFinderStyle.cs" />

Diff for: Chordious.Core/Common/Finding/FinderOptions.cs

-97
Original file line numberDiff line numberDiff line change
@@ -64,103 +64,6 @@ public string InstrumentTuningLevel
6464
}
6565
}
6666

67-
public Note RootNote
68-
{
69-
get
70-
{
71-
return Settings.GetNote(Prefix + "rootnote");
72-
}
73-
set
74-
{
75-
Settings.Set(Prefix + "rootnote", value);
76-
}
77-
}
78-
79-
public int NumFrets
80-
{
81-
get
82-
{
83-
return Settings.GetInt32(Prefix + "numfrets");
84-
}
85-
set
86-
{
87-
if (value < 0)
88-
{
89-
throw new ArgumentOutOfRangeException();
90-
}
91-
92-
Settings.Set(Prefix + "numfrets", value);
93-
94-
if (NumFrets < MaxReach)
95-
{
96-
MaxReach = NumFrets;
97-
}
98-
}
99-
}
100-
101-
public int MaxFret
102-
{
103-
get
104-
{
105-
return Settings.GetInt32(Prefix + "maxfret");
106-
}
107-
set
108-
{
109-
if (value < 0)
110-
{
111-
throw new ArgumentOutOfRangeException();
112-
}
113-
114-
Settings.Set(Prefix + "maxfret", value);
115-
}
116-
}
117-
118-
public int MaxReach
119-
{
120-
get
121-
{
122-
return Settings.GetInt32(Prefix + "maxreach");
123-
}
124-
set
125-
{
126-
if (value < 0)
127-
{
128-
throw new ArgumentOutOfRangeException();
129-
}
130-
131-
Settings.Set(Prefix + "maxreach", value);
132-
133-
if (MaxReach > NumFrets)
134-
{
135-
NumFrets = MaxReach;
136-
}
137-
}
138-
}
139-
140-
public bool AllowOpenStrings
141-
{
142-
get
143-
{
144-
return Settings.GetBoolean(Prefix + "allowopenstrings");
145-
}
146-
set
147-
{
148-
Settings.Set(Prefix + "allowopenstrings", value);
149-
}
150-
}
151-
152-
public bool AllowMutedStrings
153-
{
154-
get
155-
{
156-
return Settings.GetBoolean(Prefix + "allowmutedstrings");
157-
}
158-
set
159-
{
160-
Settings.Set(Prefix + "allowmutedstrings", value);
161-
}
162-
}
163-
16467
public bool UsingDefaultTarget
16568
{
16669
get

Diff for: Chordious.Core/Common/Finding/FinderOptions2.cs

+132
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
//
2+
// FinderOptions.cs
3+
//
4+
// Author:
5+
// Jon Thysell <[email protected]>
6+
//
7+
// Copyright (c) 2015, 2016, 2017, 2019 Jon Thysell <http://jonthysell.com>
8+
//
9+
// Permission is hereby granted, free of charge, to any person obtaining a copy
10+
// of this software and associated documentation files (the "Software"), to deal
11+
// in the Software without restriction, including without limitation the rights
12+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13+
// copies of the Software, and to permit persons to whom the Software is
14+
// furnished to do so, subject to the following conditions:
15+
//
16+
// The above copyright notice and this permission notice shall be included in
17+
// all copies or substantial portions of the Software.
18+
//
19+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25+
// THE SOFTWARE.
26+
27+
using System;
28+
29+
namespace Chordious.Core
30+
{
31+
public abstract class FinderOptions2 : FinderOptions, IFinderOptions2
32+
{
33+
public Note RootNote
34+
{
35+
get
36+
{
37+
return Settings.GetNote(Prefix + "rootnote");
38+
}
39+
set
40+
{
41+
Settings.Set(Prefix + "rootnote", value);
42+
}
43+
}
44+
45+
public int NumFrets
46+
{
47+
get
48+
{
49+
return Settings.GetInt32(Prefix + "numfrets");
50+
}
51+
set
52+
{
53+
if (value < 0)
54+
{
55+
throw new ArgumentOutOfRangeException();
56+
}
57+
58+
Settings.Set(Prefix + "numfrets", value);
59+
60+
if (NumFrets < MaxReach)
61+
{
62+
MaxReach = NumFrets;
63+
}
64+
}
65+
}
66+
67+
public int MaxFret
68+
{
69+
get
70+
{
71+
return Settings.GetInt32(Prefix + "maxfret");
72+
}
73+
set
74+
{
75+
if (value < 0)
76+
{
77+
throw new ArgumentOutOfRangeException();
78+
}
79+
80+
Settings.Set(Prefix + "maxfret", value);
81+
}
82+
}
83+
84+
public int MaxReach
85+
{
86+
get
87+
{
88+
return Settings.GetInt32(Prefix + "maxreach");
89+
}
90+
set
91+
{
92+
if (value < 0)
93+
{
94+
throw new ArgumentOutOfRangeException();
95+
}
96+
97+
Settings.Set(Prefix + "maxreach", value);
98+
99+
if (MaxReach > NumFrets)
100+
{
101+
NumFrets = MaxReach;
102+
}
103+
}
104+
}
105+
106+
public bool AllowOpenStrings
107+
{
108+
get
109+
{
110+
return Settings.GetBoolean(Prefix + "allowopenstrings");
111+
}
112+
set
113+
{
114+
Settings.Set(Prefix + "allowopenstrings", value);
115+
}
116+
}
117+
118+
public bool AllowMutedStrings
119+
{
120+
get
121+
{
122+
return Settings.GetBoolean(Prefix + "allowmutedstrings");
123+
}
124+
set
125+
{
126+
Settings.Set(Prefix + "allowmutedstrings", value);
127+
}
128+
}
129+
130+
protected FinderOptions2(ConfigFile configFile, string prefix) : base(configFile, prefix) { }
131+
}
132+
}

Diff for: Chordious.Core/Common/Finding/IFinderOptions.cs

-8
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,5 @@ public interface IFinderOptions
3030
{
3131
IInstrument Instrument { get; }
3232
ITuning Tuning { get; }
33-
34-
Note RootNote { get; }
35-
36-
int NumFrets { get; }
37-
int MaxFret { get; }
38-
int MaxReach { get; }
39-
bool AllowOpenStrings { get; }
40-
bool AllowMutedStrings { get; }
4133
}
4234
}

Diff for: Chordious.Core/Common/Finding/IFinderOptions2.cs

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
//
2+
// IFinderOptions2.cs
3+
//
4+
// Author:
5+
// Jon Thysell <[email protected]>
6+
//
7+
// Copyright (c) 2016, 2017, 2019 Jon Thysell <http://jonthysell.com>
8+
//
9+
// Permission is hereby granted, free of charge, to any person obtaining a copy
10+
// of this software and associated documentation files (the "Software"), to deal
11+
// in the Software without restriction, including without limitation the rights
12+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13+
// copies of the Software, and to permit persons to whom the Software is
14+
// furnished to do so, subject to the following conditions:
15+
//
16+
// The above copyright notice and this permission notice shall be included in
17+
// all copies or substantial portions of the Software.
18+
//
19+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25+
// THE SOFTWARE.
26+
27+
namespace Chordious.Core
28+
{
29+
public interface IFinderOptions2 : IFinderOptions
30+
{
31+
Note RootNote { get; }
32+
33+
int NumFrets { get; }
34+
int MaxFret { get; }
35+
int MaxReach { get; }
36+
bool AllowOpenStrings { get; }
37+
bool AllowMutedStrings { get; }
38+
}
39+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
//
2+
// IReverseChordFinderOptions.cs
3+
//
4+
// Author:
5+
// Jon Thysell <[email protected]>
6+
//
7+
// Copyright (c) 2019 Jon Thysell <http://jonthysell.com>
8+
//
9+
// Permission is hereby granted, free of charge, to any person obtaining a copy
10+
// of this software and associated documentation files (the "Software"), to deal
11+
// in the Software without restriction, including without limitation the rights
12+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13+
// copies of the Software, and to permit persons to whom the Software is
14+
// furnished to do so, subject to the following conditions:
15+
//
16+
// The above copyright notice and this permission notice shall be included in
17+
// all copies or substantial portions of the Software.
18+
//
19+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25+
// THE SOFTWARE.
26+
27+
namespace Chordious.Core
28+
{
29+
public interface IReverseChordFinderOptions : IFinderOptions
30+
{
31+
int[] Marks { get; }
32+
}
33+
}

0 commit comments

Comments
 (0)