Skip to content

Commit 4f734a2

Browse files
authored
Merge pull request #1618 from SCIInstitute/split-up-headers
Big clean up of Module and Algo headers
2 parents e945e84 + 31f3d12 commit 4f734a2

File tree

153 files changed

+2271
-1706
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

153 files changed

+2271
-1706
lines changed

src/Core/Algorithms/Base/AlgorithmBase.cc

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,6 @@ Name::Name(const std::string& name) : name_(name)
6060
}
6161
}
6262

63-
AlgorithmBase::~AlgorithmBase() {}
64-
6563
namespace
6664
{
6765
// Note: boost::serialization has trouble with NaN values, in addition to the platform differences.
@@ -381,10 +379,10 @@ bool AlgorithmParameterList::checkOption(const AlgorithmParameterName& key, cons
381379
return boost::iequals(value, currentValue);
382380
}
383381

384-
void AlgorithmBase::dumpAlgoState() const
382+
void AlgorithmParameterList::dumpAlgoState() const
385383
{
386384
std::ostringstream ostr;
387-
ostr << "Algorithm state for " << typeid(*this).name() << " id#" << id() << std::endl;
385+
ostr << "Algorithm state for " << typeid(*this).name() << std::endl;
388386

389387
auto range = std::make_pair(paramsBegin(), paramsEnd());
390388
BOOST_FOREACH(const ParameterMap::value_type& pair, range)
@@ -466,4 +464,4 @@ std::vector<std::string> Core::Algorithms::toNameVector(const Variable::List& li
466464
std::vector<double> Core::Algorithms::toDoubleVector(const Variable::List& list)
467465
{
468466
return toTypedVector<double>(list, [](const Variable& v) { return v.toDouble(); });
469-
}
467+
}

src/Core/Algorithms/Base/AlgorithmBase.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,15 @@
3939
namespace SCIRun {
4040
namespace Core {
4141
namespace Algorithms {
42-
43-
class SCISHARE AlgorithmBase : public AlgorithmInterface, public AlgorithmParameterList, public AlgorithmLogger, public AlgorithmStatusReporter
42+
43+
class SCISHARE AlgorithmBase :
44+
public AlgorithmInterface,
45+
public AlgorithmParameterList,
46+
public AlgorithmLogger,
47+
public AlgorithmStatusReporter
4448
{
45-
public:
46-
virtual ~AlgorithmBase();
47-
protected:
48-
void dumpAlgoState() const;
4949
};
50-
50+
5151
}}}
5252

5353
#endif

src/Core/Algorithms/Base/AlgorithmData.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ namespace Algorithms {
5555
{
5656
auto it = data_.find(name);
5757
/// @todo: log incorrect type if present but wrong type
58-
return it == data_.end() ? boost::shared_ptr<T>() : boost::dynamic_pointer_cast<T>(it->second[0]);
58+
return it == data_.end() ? nullptr : boost::dynamic_pointer_cast<T>(it->second[0]);
5959
}
6060

6161
template <typename T>
@@ -81,11 +81,11 @@ namespace Algorithms {
8181
boost::any transient_;
8282
};
8383

84-
class SCISHARE AlgorithmInput : public AlgorithmData
84+
class SCISHARE AlgorithmInput : public AlgorithmData
8585
{
8686
public:
8787
AlgorithmInput() {}
88-
AlgorithmInput(const Map& m) : AlgorithmData(m) {}
88+
explicit AlgorithmInput(const Map& m) : AlgorithmData(m) {}
8989
};
9090

9191
class SCISHARE AlgorithmOutput : public AlgorithmData
@@ -97,9 +97,9 @@ namespace Algorithms {
9797
VariableHandle additionalAlgoOutput_;
9898
};
9999

100-
typedef Datatypes::SharedPointer<AlgorithmInput> AlgorithmInputHandle;
101-
typedef Datatypes::SharedPointer<AlgorithmOutput> AlgorithmOutputHandle;
102-
100+
typedef SharedPointer<AlgorithmInput> AlgorithmInputHandle;
101+
typedef SharedPointer<AlgorithmOutput> AlgorithmOutputHandle;
102+
103103
}}}
104104

105105
#endif

src/Core/Algorithms/Base/AlgorithmFwd.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,19 @@
3030
#define ALGORITHMS_BASE_ALGORITHMFWD_H
3131

3232
#include <Core/Datatypes/DatatypeFwd.h>
33+
#include <Core/Utils/SmartPointers.h>
3334
#include <Core/Algorithms/Base/share.h>
3435

3536
namespace SCIRun {
3637
namespace Core {
3738
namespace Algorithms {
3839

3940
class AlgorithmBase;
40-
typedef Datatypes::SharedPointer<AlgorithmBase> AlgorithmHandle;
41+
typedef SharedPointer<AlgorithmBase> AlgorithmHandle;
4142

4243
class AlgorithmFactory;
43-
typedef Datatypes::SharedPointer<AlgorithmFactory> AlgorithmFactoryHandle;
44+
typedef SharedPointer<AlgorithmFactory> AlgorithmFactoryHandle;
4445

4546
}}}
4647

47-
#endif
48+
#endif

src/Core/Algorithms/Base/AlgorithmInterfaces.h

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,22 +36,11 @@
3636
namespace SCIRun {
3737
namespace Core {
3838
namespace Algorithms {
39-
39+
4040
class SCISHARE AlgorithmInterface : public HasIntegerId
4141
{
4242
public:
4343
virtual ~AlgorithmInterface() {}
44-
45-
/*
46-
@todo idea: make it mockable
47-
48-
virtual OutputDatatypeHandleOptions run(InputDatatypeHandleOptions, ModuleParameterState) = 0;
49-
50-
ModuleParameterState: essentially a map of GuiVars. but need hooks for undo/redo and serialization
51-
Input: tuple/heterogeneous vector of Datatypes
52-
Output: tuple of Datatypes, possibly delay-executed
53-
*/
54-
5544
virtual AlgorithmOutput run(const AlgorithmInput& input) const = 0;
5645
};
5746

src/Core/Algorithms/Base/AlgorithmParameterList.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,11 @@ namespace Algorithms {
7373
typedef std::map<AlgorithmParameterName, AlgorithmParameter> ParameterMap;
7474
ParameterMap::const_iterator paramsBegin() const { return parameters_.begin(); }
7575
ParameterMap::const_iterator paramsEnd() const { return parameters_.end(); }
76+
void dumpAlgoState() const;
7677
private:
7778
ParameterMap parameters_;
7879
};
79-
80+
8081
}}}
8182

8283
#endif

src/Core/Algorithms/Base/AlgorithmStatusReporter.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ namespace Algorithms {
5252
virtual void update_progress(double percent) const
5353
{
5454
if (updaterFunc_)
55-
updaterFunc_(percent);
55+
updaterFunc_(percent);
5656
}
5757

5858
typedef boost::function<void(double)> UpdaterFunc;
@@ -72,6 +72,8 @@ namespace Algorithms {
7272
const AlgorithmStatusReporter* asr_;
7373
};
7474

75+
#define REPORT_STATUS(className) ScopedAlgorithmStatusReporter __asr(this, #className);
76+
7577
}}}
7678

7779
#endif

src/Core/Algorithms/Base/Variable.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
#include <boost/iterator/counting_iterator.hpp>
3939
#endif
4040
#include <Core/Datatypes/DatatypeFwd.h>
41+
#include <Core/Algorithms/Base/AlgorithmFwd.h>
4142
#include <Core/Algorithms/Base/Name.h>
4243
#include <Core/Algorithms/Base/Option.h>
4344
#include <Core/Algorithms/Base/share.h>
@@ -49,16 +50,15 @@ namespace Algorithms {
4950
class SCISHARE Variable
5051
{
5152
public:
52-
typedef std::vector<Variable> List;
53-
54-
typedef boost::variant<
53+
using List = std::vector<Variable>;
54+
using Value = boost::variant<
5555
int,
5656
double,
5757
std::string,
5858
bool,
5959
AlgoOption,
6060
List
61-
> Value;
61+
>;
6262

6363
Variable() {}
6464
Variable(const Name& name, const Value& value);
@@ -109,7 +109,7 @@ namespace Algorithms {
109109
Variable::List makeNamedVariableList(const Name (&namesList)[N], Ts&&... params)
110110
{
111111
std::vector<Variable::Value> values{ params... };
112-
112+
113113
auto namesIter = &namesList[0];
114114
Variable::List vars;
115115
std::transform(values.begin(), values.end(), std::back_inserter(vars),
@@ -139,7 +139,7 @@ namespace Algorithms {
139139

140140
typedef Variable AlgorithmParameter;
141141
typedef Variable::List VariableList;
142-
typedef Datatypes::SharedPointer<Variable> VariableHandle;
142+
typedef SharedPointer<Variable> VariableHandle;
143143

144144
}
145145

src/Core/Algorithms/DataIO/Tests/ReadMatrixTests.cc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,6 @@ TEST(ReadMatrixAlgorithmTest, TestDenseFromRealASCIIMatFile)
128128
ASSERT_TRUE(matrixIs::dense(matrix));
129129

130130
auto dense = castMatrix::toDense(matrix);
131-
double* ptr = dense->data();
132-
size_t size = dense->get_dense_size();
133131

134132
EXPECT_EQ(4, dense->cols());
135133
EXPECT_EQ(3, dense->rows());

0 commit comments

Comments
 (0)