15 #include <morphio/enums.h>
16 #include <morphio/types.h>
21 std::string errorLink(
const std::string& uri,
22 long unsigned int lineNumber,
23 morphio::readers::ErrorLevel errorLevel);
29 : uri(std::move(uri_)) {}
34 virtual std::string msg()
const = 0;
44 , lineNumber(lineNumber_) {}
46 return Warning::ZERO_DIAMETER;
48 morphio::readers::ErrorLevel errorLevel = morphio::readers::ErrorLevel::WARNING;
49 std::string msg()
const final {
50 static const char* description =
"Warning: zero diameter in file";
51 return "\n" + details::errorLink(uri, lineNumber, errorLevel) + description;
60 , lineNumber(lineNumber_) {}
62 return Warning::DISCONNECTED_NEURITE;
64 morphio::readers::ErrorLevel errorLevel = morphio::readers::ErrorLevel::WARNING;
65 std::string msg()
const final {
66 static const char* description =
67 "Warning: found a disconnected neurite.\n"
68 "Neurites are not supposed to have parentId: -1\n"
69 "(although this is normal if this neuron has no soma)";
70 return "\n" + details::errorLink(uri, lineNumber, errorLevel) + description;
80 return Warning::NO_SOMA_FOUND;
82 morphio::readers::ErrorLevel errorLevel = morphio::readers::ErrorLevel::WARNING;
83 std::string msg()
const final {
84 static const char* description =
"Warning: no soma found in file";
85 return "\n" + details::errorLink(uri, 0, errorLevel) + description;
90 explicit SomaNonConform(std::string uri_, std::string description_)
92 , description(std::move(description_)) {}
94 return Warning::SOMA_NON_CONFORM;
96 morphio::readers::ErrorLevel errorLevel = morphio::readers::ErrorLevel::WARNING;
97 std::string msg()
const final {
98 return "\n" + details::errorLink(uri, 0, errorLevel) + description;
100 std::string description;
104 explicit WrongRootPoint(std::string uri_, std::vector<unsigned int> lineNumbers_)
106 , lineNumbers(std::move(lineNumbers_)) {}
107 Warning warning()
const final {
108 return Warning::WRONG_ROOT_POINT;
110 morphio::readers::ErrorLevel errorLevel = morphio::readers::ErrorLevel::WARNING;
111 std::string msg()
const final {
112 std::ostringstream oss;
113 oss <<
"Warning: with a 3 points soma, neurites must be connected to the first soma point:";
114 for (
const auto& lineNumber : lineNumbers) {
115 oss <<
"\n" + details::errorLink(uri, lineNumber, errorLevel);
119 std::vector<unsigned int> lineNumbers;
125 , sectionId(sectionId_) {}
126 Warning warning()
const final {
127 return Warning::APPENDING_EMPTY_SECTION;
129 morphio::readers::ErrorLevel errorLevel = morphio::readers::ErrorLevel::WARNING;
130 std::string msg()
const final {
131 static const char* description =
"Warning: appending empty section with id: ";
132 return "\n" + details::errorLink(uri, 0, errorLevel) + description +
133 std::to_string(sectionId);
140 std::shared_ptr<morphio::mut::Section> current_,
141 std::shared_ptr<morphio::mut::Section> parent_)
143 , current(std::move(current_))
144 , parent(std::move(parent_)) {}
145 std::string msg()
const final;
147 Warning warning()
const final {
148 return Warning::WRONG_DUPLICATE;
150 morphio::readers::ErrorLevel errorLevel = morphio::readers::ErrorLevel::WARNING;
151 std::shared_ptr<morphio::mut::Section> current;
152 std::shared_ptr<morphio::mut::Section> parent;
156 explicit OnlyChild(std::string uri_,
unsigned int parentId_,
unsigned int childId_)
158 , parentId(parentId_)
159 , childId(childId_) {}
160 Warning warning()
const final {
161 return Warning::ONLY_CHILD;
163 morphio::readers::ErrorLevel errorLevel = morphio::readers::ErrorLevel::WARNING;
164 std::string msg()
const final {
165 std::ostringstream oss;
166 oss <<
"Warning: section " << childId <<
" is the only child of "
167 <<
"section: " << std::to_string(parentId)
168 <<
"\nIt will be merged with the parent section";
170 return "\n" + details::errorLink(uri, 0, errorLevel) + oss.str();
172 unsigned int parentId;
173 unsigned int childId;
179 Warning warning()
const final {
180 return Warning::WRITE_NO_SOMA;
182 morphio::readers::ErrorLevel errorLevel = morphio::readers::ErrorLevel::WARNING;
183 std::string msg()
const final {
184 static const char* description =
"Warning: writing file without a soma";
185 return "\n" + details::errorLink(uri, 0, errorLevel) + description;
192 Warning warning()
const final {
193 return Warning::WRITE_EMPTY_MORPHOLOGY;
195 morphio::readers::ErrorLevel errorLevel = morphio::readers::ErrorLevel::WARNING;
196 std::string msg()
const final {
197 static const char* description =
198 "Warning: Skipping an attempt to write an empty morphology.";
199 return "\n" + details::errorLink(uri, 0, errorLevel) + description;
206 Warning warning()
const final {
207 return Warning::WRITE_UNDEFINED_SOMA;
209 morphio::readers::ErrorLevel errorLevel = morphio::readers::ErrorLevel::WARNING;
210 std::string msg()
const final {
211 static const char* description =
"Warning: writing soma set to SOMA_UNDEFINED";
212 return "\n" + details::errorLink(uri, 0, errorLevel) + description;
219 Warning warning()
const final {
220 return Warning::MITOCHONDRIA_WRITE_NOT_SUPPORTED;
222 morphio::readers::ErrorLevel errorLevel = morphio::readers::ErrorLevel::WARNING;
223 std::string msg()
const final {
224 static const char* description =
225 "Warning: this cell has mitochondria, they cannot be saved in "
226 " ASC or SWC format. Please use H5 if you want to save them.";
227 return "\n" + details::errorLink(uri, 0, errorLevel) + description;
234 Warning warning()
const final {
235 return Warning::SOMA_NON_CONTOUR;
237 morphio::readers::ErrorLevel errorLevel = morphio::readers::ErrorLevel::WARNING;
238 std::string msg()
const final {
239 static const char* description =
240 "Soma must be a contour for ASC and H5: see "
241 "https://github.com/BlueBrain/MorphIO/issues/457";
242 return "\n" + details::errorLink(uri, 0, errorLevel) + description;
249 Warning warning()
const final {
250 return Warning::SOMA_NON_CYLINDER_OR_POINT;
252 morphio::readers::ErrorLevel errorLevel = morphio::readers::ErrorLevel::WARNING;
253 std::string msg()
const final {
254 static const char* description =
255 "Soma must be stacked cylinders or a point: see "
256 "https://github.com/BlueBrain/MorphIO/issues/457";
257 return "\n" + details::errorLink(uri, 0, errorLevel) + description;
271 virtual void emit(std::shared_ptr<WarningMessage>) = 0;
278 virtual int getMaxWarningCount()
const = 0;
279 virtual void setMaxWarningCount(
int warningCount) = 0;
280 virtual bool getRaiseWarnings()
const = 0;
281 virtual void setRaiseWarnings(
bool raise) = 0;
284 std::set<enums::Warning> ignoredWarnings_;
291 int getMaxWarningCount()
const final;
292 void setMaxWarningCount(
int warningCount)
final;
293 bool getRaiseWarnings()
const final;
294 void setRaiseWarnings(
bool raise)
final;
295 void emit(std::shared_ptr<morphio::WarningMessage> wm)
final;
298 uint32_t errorCount = 0;
299 int32_t maxWarningCount_ = 100;
300 bool raiseWarnings_ =
false;
308 Emission(
bool wasMarkedIgnore_, std::shared_ptr<WarningMessage> warning_)
309 : wasMarkedIgnore(wasMarkedIgnore_)
310 , warning(std::move(warning_)) {}
311 bool wasMarkedIgnore =
false;
312 std::shared_ptr<WarningMessage> warning;
315 int getMaxWarningCount() const final;
316 void setMaxWarningCount(
int warningCount) final;
317 bool getRaiseWarnings() const final;
318 void setRaiseWarnings(
bool raise) final;
321 std::vector<
Emission> getAll() const;