Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
mantid
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mantidproject
mantid
Commits
f78f027f
Commit
f78f027f
authored
7 years ago
by
Savici, Andrei T.
Committed by
GitHub
7 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #19902 from mantidproject/algorithm_headers2
Algorithm headers
parents
59357f1a
ff8f5355
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Framework/API/inc/MantidAPI/Algorithm.h
+18
-37
18 additions, 37 deletions
Framework/API/inc/MantidAPI/Algorithm.h
Framework/API/src/Algorithm.cpp
+47
-0
47 additions, 0 deletions
Framework/API/src/Algorithm.cpp
with
65 additions
and
37 deletions
Framework/API/inc/MantidAPI/Algorithm.h
+
18
−
37
View file @
f78f027f
...
...
@@ -92,52 +92,40 @@ class MANTID_API_DLL Algorithm : public IAlgorithm,
public
Kernel
::
PropertyManagerOwner
{
public:
/// Base class for algorithm notifications
class
AlgorithmNotification
:
public
Poco
::
Notification
{
class
MANTID_API_DLL
AlgorithmNotification
:
public
Poco
::
Notification
{
public:
AlgorithmNotification
(
const
Algorithm
*
const
alg
)
:
Poco
::
Notification
(),
m_algorithm
(
alg
)
{}
///< Constructor
const
IAlgorithm
*
algorithm
()
const
{
return
m_algorithm
;
}
///< The algorithm
AlgorithmNotification
(
const
Algorithm
*
const
alg
);
const
IAlgorithm
*
algorithm
()
const
;
private:
const
IAlgorithm
*
const
m_algorithm
;
///< The algorithm
};
/// StartedNotification is sent when the algorithm begins execution.
class
StartedNotification
:
public
AlgorithmNotification
{
class
MANTID_API_DLL
StartedNotification
:
public
AlgorithmNotification
{
public:
StartedNotification
(
const
Algorithm
*
const
alg
)
:
AlgorithmNotification
(
alg
)
{}
///< Constructor
std
::
string
name
()
const
override
{
return
"StartedNotification"
;
}
///< class name
StartedNotification
(
const
Algorithm
*
const
alg
);
std
::
string
name
()
const
override
;
};
/// FinishedNotification is sent after the algorithm finishes its execution
class
FinishedNotification
:
public
AlgorithmNotification
{
class
MANTID_API_DLL
FinishedNotification
:
public
AlgorithmNotification
{
public:
FinishedNotification
(
const
Algorithm
*
const
alg
,
bool
res
)
:
AlgorithmNotification
(
alg
),
success
(
res
)
{}
///< Constructor
std
::
string
name
()
const
override
{
return
"FinishedNotification"
;
}
///< class name
FinishedNotification
(
const
Algorithm
*
const
alg
,
bool
res
);
std
::
string
name
()
const
override
;
bool
success
;
///< true if the finished algorithm was successful or false if
/// it failed.
};
/// An algorithm can report its progress by sending ProgressNotification. Use
/// Algorithm::progress(double) function to send a progress notification.
class
ProgressNotification
:
public
AlgorithmNotification
{
class
MANTID_API_DLL
ProgressNotification
:
public
AlgorithmNotification
{
public:
/// Constructor
ProgressNotification
(
const
Algorithm
*
const
alg
,
double
p
,
const
std
::
string
&
msg
,
double
estimatedTime
,
int
progressPrecision
)
:
AlgorithmNotification
(
alg
),
progress
(
p
),
message
(
msg
),
estimatedTime
(
estimatedTime
),
progressPrecision
(
progressPrecision
)
{}
std
::
string
name
()
const
override
{
return
"ProgressNotification"
;
}
///< class name
int
progressPrecision
);
std
::
string
name
()
const
override
;
double
progress
;
///< Current progress. Value must be between 0 and 1.
std
::
string
message
;
///< Message sent with notification
double
estimatedTime
;
///<Estimated time to completion
...
...
@@ -147,14 +135,11 @@ public:
/// ErrorNotification is sent when an exception is caught during execution of
/// the algorithm.
class
ErrorNotification
:
public
AlgorithmNotification
{
class
MANTID_API_DLL
ErrorNotification
:
public
AlgorithmNotification
{
public:
/// Constructor
ErrorNotification
(
const
Algorithm
*
const
alg
,
const
std
::
string
&
str
)
:
AlgorithmNotification
(
alg
),
what
(
str
)
{}
std
::
string
name
()
const
override
{
return
"ErrorNotification"
;
}
///< class name
ErrorNotification
(
const
Algorithm
*
const
alg
,
const
std
::
string
&
str
);
std
::
string
name
()
const
override
;
std
::
string
what
;
///< message string
};
...
...
@@ -165,14 +150,10 @@ public:
/// periodically Algorithm::interuption_point() which checks if
/// Algorithm::cancel() has been called
/// and throws CancelException if needed.
class
CancelException
:
public
std
::
exception
{
class
MANTID_API_DLL
CancelException
:
public
std
::
exception
{
public:
/// Returns the message string.
const
char
*
what
()
const
noexcept
override
{
return
outMessage
.
c_str
();
}
private
:
/// The message returned by what()
std
::
string
outMessage
{
"Algorithm terminated"
};
const
char
*
what
()
const
noexcept
override
;
};
//============================================================================
...
...
This diff is collapsed.
Click to expand it.
Framework/API/src/Algorithm.cpp
+
47
−
0
View file @
f78f027f
...
...
@@ -1769,6 +1769,53 @@ void Algorithm::setCommunicator(const Parallel::Communicator &communicator) {
m_communicator
=
Kernel
::
make_unique
<
Parallel
::
Communicator
>
(
communicator
);
}
//---------------------------------------------------------------------------
// Algorithm's inner classes
//---------------------------------------------------------------------------
Algorithm
::
AlgorithmNotification
::
AlgorithmNotification
(
const
Algorithm
*
const
alg
)
:
Poco
::
Notification
(),
m_algorithm
(
alg
)
{}
const
IAlgorithm
*
Algorithm
::
AlgorithmNotification
::
algorithm
()
const
{
return
m_algorithm
;
}
Algorithm
::
StartedNotification
::
StartedNotification
(
const
Algorithm
*
const
alg
)
:
AlgorithmNotification
(
alg
)
{}
std
::
string
Algorithm
::
StartedNotification
::
name
()
const
{
return
"StartedNotification"
;
}
///< class name
Algorithm
::
FinishedNotification
::
FinishedNotification
(
const
Algorithm
*
const
alg
,
bool
res
)
:
AlgorithmNotification
(
alg
),
success
(
res
)
{}
std
::
string
Algorithm
::
FinishedNotification
::
name
()
const
{
return
"FinishedNotification"
;
}
Algorithm
::
ProgressNotification
::
ProgressNotification
(
const
Algorithm
*
const
alg
,
double
p
,
const
std
::
string
&
msg
,
double
estimatedTime
,
int
progressPrecision
)
:
AlgorithmNotification
(
alg
),
progress
(
p
),
message
(
msg
),
estimatedTime
(
estimatedTime
),
progressPrecision
(
progressPrecision
)
{}
std
::
string
Algorithm
::
ProgressNotification
::
name
()
const
{
return
"ProgressNotification"
;
}
Algorithm
::
ErrorNotification
::
ErrorNotification
(
const
Algorithm
*
const
alg
,
const
std
::
string
&
str
)
:
AlgorithmNotification
(
alg
),
what
(
str
)
{}
std
::
string
Algorithm
::
ErrorNotification
::
name
()
const
{
return
"ErrorNotification"
;
}
const
char
*
Algorithm
::
CancelException
::
what
()
const
noexcept
{
return
"Algorithm terminated"
;
}
}
// namespace API
//---------------------------------------------------------------------------
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment