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::SECTION_TYPE_CHANGED;
64 morphio::readers::ErrorLevel errorLevel = morphio::readers::ErrorLevel::WARNING;
65 std::string msg()
const final {
66 static const char* description =
67 "Warning: Type changed within section, without bifurcation";
68 return "\n" + details::errorLink(uri, lineNumber, errorLevel) + description;
77 , lineNumber(lineNumber_) {}
79 return Warning::DISCONNECTED_NEURITE;
81 morphio::readers::ErrorLevel errorLevel = morphio::readers::ErrorLevel::WARNING;
82 std::string msg()
const final {
83 static const char* description =
84 "Warning: found a disconnected neurite.\n"
85 "Neurites are not supposed to have parentId: -1\n"
86 "(although this is normal if this neuron has no soma)";
87 return "\n" + details::errorLink(uri, lineNumber, errorLevel) + description;
97 return Warning::NO_SOMA_FOUND;
99 morphio::readers::ErrorLevel errorLevel = morphio::readers::ErrorLevel::WARNING;
100 std::string msg()
const final {
101 static const char* description =
"Warning: no soma found in file";
102 return "\n" + details::errorLink(uri, 0, errorLevel) + description;
107 explicit SomaNonConform(std::string uri_, std::string description_)
109 , description(std::move(description_)) {}
110 Warning warning()
const final {
111 return Warning::SOMA_NON_CONFORM;
113 morphio::readers::ErrorLevel errorLevel = morphio::readers::ErrorLevel::WARNING;
114 std::string msg()
const final {
115 return "\n" + details::errorLink(uri, 0, errorLevel) + description;
117 std::string description;
121 explicit WrongRootPoint(std::string uri_, std::vector<unsigned int> lineNumbers_)
123 , lineNumbers(std::move(lineNumbers_)) {}
124 Warning warning()
const final {
125 return Warning::WRONG_ROOT_POINT;
127 morphio::readers::ErrorLevel errorLevel = morphio::readers::ErrorLevel::WARNING;
128 std::string msg()
const final {
129 std::ostringstream oss;
130 oss <<
"Warning: with a 3 points soma, neurites must be connected to the first soma point:";
131 for (
const auto& lineNumber : lineNumbers) {
132 oss <<
"\n" + details::errorLink(uri, lineNumber, errorLevel);
136 std::vector<unsigned int> lineNumbers;
142 , sectionId(sectionId_) {}
143 Warning warning()
const final {
144 return Warning::APPENDING_EMPTY_SECTION;
146 morphio::readers::ErrorLevel errorLevel = morphio::readers::ErrorLevel::WARNING;
147 std::string msg()
const final {
148 static const char* description =
"Warning: appending empty section with id: ";
149 return "\n" + details::errorLink(uri, 0, errorLevel) + description +
150 std::to_string(sectionId);
157 std::shared_ptr<morphio::mut::Section> current_,
158 std::shared_ptr<morphio::mut::Section> parent_)
160 , current(std::move(current_))
161 , parent(std::move(parent_)) {}
162 std::string msg()
const final;
164 Warning warning()
const final {
165 return Warning::WRONG_DUPLICATE;
167 morphio::readers::ErrorLevel errorLevel = morphio::readers::ErrorLevel::WARNING;
168 std::shared_ptr<morphio::mut::Section> current;
169 std::shared_ptr<morphio::mut::Section> parent;
173 explicit OnlyChild(std::string uri_,
unsigned int parentId_,
unsigned int childId_)
175 , parentId(parentId_)
176 , childId(childId_) {}
177 Warning warning()
const final {
178 return Warning::ONLY_CHILD;
180 morphio::readers::ErrorLevel errorLevel = morphio::readers::ErrorLevel::WARNING;
181 std::string msg()
const final {
182 std::ostringstream oss;
183 oss <<
"Warning: section " << childId <<
" is the only child of "
184 <<
"section: " << std::to_string(parentId)
185 <<
"\nIt will be merged with the parent section";
187 return "\n" + details::errorLink(uri, 0, errorLevel) + oss.str();
189 unsigned int parentId;
190 unsigned int childId;
196 Warning warning()
const final {
197 return Warning::WRITE_NO_SOMA;
199 morphio::readers::ErrorLevel errorLevel = morphio::readers::ErrorLevel::WARNING;
200 std::string msg()
const final {
201 static const char* description =
"Warning: writing file without a soma";
202 return "\n" + details::errorLink(uri, 0, errorLevel) + description;
209 Warning warning()
const final {
210 return Warning::WRITE_EMPTY_MORPHOLOGY;
212 morphio::readers::ErrorLevel errorLevel = morphio::readers::ErrorLevel::WARNING;
213 std::string msg()
const final {
214 static const char* description =
215 "Warning: Skipping an attempt to write an empty morphology.";
216 return "\n" + details::errorLink(uri, 0, errorLevel) + description;
223 Warning warning()
const final {
224 return Warning::WRITE_UNDEFINED_SOMA;
226 morphio::readers::ErrorLevel errorLevel = morphio::readers::ErrorLevel::WARNING;
227 std::string msg()
const final {
228 static const char* description =
"Warning: writing soma set to SOMA_UNDEFINED";
229 return "\n" + details::errorLink(uri, 0, errorLevel) + description;
236 Warning warning()
const final {
237 return Warning::MITOCHONDRIA_WRITE_NOT_SUPPORTED;
239 morphio::readers::ErrorLevel errorLevel = morphio::readers::ErrorLevel::WARNING;
240 std::string msg()
const final {
241 static const char* description =
242 "Warning: this cell has mitochondria, they cannot be saved in "
243 " ASC or SWC format. Please use H5 if you want to save them.";
244 return "\n" + details::errorLink(uri, 0, errorLevel) + description;
251 Warning warning()
const final {
252 return Warning::SOMA_NON_CONTOUR;
254 morphio::readers::ErrorLevel errorLevel = morphio::readers::ErrorLevel::WARNING;
255 std::string msg()
const final {
256 static const char* description =
257 "Soma must be a contour for ASC and H5: see "
258 "https://github.com/BlueBrain/MorphIO/issues/457";
259 return "\n" + details::errorLink(uri, 0, errorLevel) + description;
266 Warning warning()
const final {
267 return Warning::SOMA_NON_CYLINDER_OR_POINT;
269 morphio::readers::ErrorLevel errorLevel = morphio::readers::ErrorLevel::WARNING;
270 std::string msg()
const final {
271 static const char* description =
272 "Soma must be stacked cylinders or a point: see "
273 "https://github.com/BlueBrain/MorphIO/issues/457";
274 return "\n" + details::errorLink(uri, 0, errorLevel) + description;
288 virtual void emit(std::shared_ptr<WarningMessage>) = 0;
295 virtual int getMaxWarningCount()
const = 0;
296 virtual void setMaxWarningCount(
int warningCount) = 0;
297 virtual bool getRaiseWarnings()
const = 0;
298 virtual void setRaiseWarnings(
bool raise) = 0;
301 std::set<enums::Warning> ignoredWarnings_;
308 int getMaxWarningCount()
const final;
309 void setMaxWarningCount(
int warningCount)
final;
310 bool getRaiseWarnings()
const final;
311 void setRaiseWarnings(
bool raise)
final;
312 void emit(std::shared_ptr<morphio::WarningMessage> wm)
final;
315 uint32_t errorCount = 0;
316 int32_t maxWarningCount_ = 100;
317 bool raiseWarnings_ =
false;
325 Emission(
bool wasMarkedIgnore_, std::shared_ptr<WarningMessage> warning_)
326 : wasMarkedIgnore(wasMarkedIgnore_)
327 , warning(std::move(warning_)) {}
328 bool wasMarkedIgnore =
false;
329 std::shared_ptr<WarningMessage> warning;
332 int getMaxWarningCount() const final;
333 void setMaxWarningCount(
int warningCount) final;
334 bool getRaiseWarnings() const final;
335 void setRaiseWarnings(
bool raise) final;
338 std::vector<
Emission> getAll() const;