Tissue Forge C++ 0.2.1
Interactive, particle-based physics, chemistry and biology modeling and simulation environment
Loading...
Searching...
No Matches
tfMeshLogger.h
Go to the documentation of this file.
1/*******************************************************************************
2 * This file is part of Tissue Forge.
3 * Copyright (c) 2022-2024 T.J. Sego and Tien Comlekoglu
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU Lesser General Public License as published
7 * by the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 *
18 ******************************************************************************/
19
25#ifndef _MODELS_VERTEX_SOLVER_TFMESHLOGGER_H_
26#define _MODELS_VERTEX_SOLVER_TFMESHLOGGER_H_
27
28#include <tf_port.h>
29#include <tfLogger.h>
30#include <types/tf_cast.h>
31
32#include "tfMeshObj.h"
33
34#include <string>
35#include <vector>
36
37
38namespace TissueForge::models::vertex {
39
40
46 None = 0,
47 Create,
48 Destroy,
49 Operation
50 };
51
56 struct CAPI_EXPORT MeshLogEvent {
58 std::vector<int> objIDs;
59 std::vector<MeshObjTypeLabel> objTypes;
60 std::string name;
61 };
62
67 struct CAPI_EXPORT MeshLogger {
68
72 static HRESULT clear();
73
79 static HRESULT log(const MeshLogEvent &event);
80
84 static std::vector<MeshLogEvent> events();
85
89 static bool getForwardLogging();
90
96 static HRESULT setForwardLogging(const bool &_forward);
97
102
108 static HRESULT setLogLevel(const LogLevel &_level);
109
110 };
111
112}
113
114
115inline std::ostream& operator<<(std::ostream& os, const TissueForge::models::vertex::MeshLogEvent &logEvent)
116{
117 os << "{";
118
119 switch (logEvent.type)
120 {
121 case TissueForge::models::vertex::MeshLogEventType::Create:
122 os << "Create";
123 break;
124
125 case TissueForge::models::vertex::MeshLogEventType::Destroy:
126 os << "Destroy";
127 break;
128
129 case TissueForge::models::vertex::MeshLogEventType::Operation:
130 os << "Operation";
131 break;
132
133 default:
134 os << "None";
135 break;
136 }
137
138 os << " (" << logEvent.name << "): (";
139 if(logEvent.objIDs.size() > 0) {
140 os << logEvent.objIDs[0];
141 for(int i = 1; i < logEvent.objIDs.size(); i++) os << ", " << logEvent.objIDs[i];
142 }
143 os << "), (";
144 if(logEvent.objTypes.size() > 0) {
145 os << logEvent.objTypes[0];
146 for(int i = 1; i < logEvent.objTypes.size(); i++) os << ", " << logEvent.objTypes[i];
147 }
148 os << ")}";
149 return os;
150}
151
152template<>
153inline std::string TissueForge::cast(const TissueForge::models::vertex::MeshLogEvent &logEvent) {
154 std::stringstream ss;
155 ss << logEvent;
156 return ss.str();
157}
158
159#endif // _MODELS_VERTEX_SOLVER_TFMESHLOGGER_H_
LogLevel
Definition tfLogger.h:59
An event for the logger.
Definition tfMeshLogger.h:56
The Tissue Forge vertex model solver logger.
Definition tfMeshLogger.h:67
static HRESULT setLogLevel(const LogLevel &_level)
Set the current log level.
static HRESULT setForwardLogging(const bool &_forward)
Set whether to foward log events to the main Tissue Forge logger.
static HRESULT log(const MeshLogEvent &event)
Add a log event to the log.
static LogLevel getLogLevel()
Get the current log level.
static std::vector< MeshLogEvent > events()
Get the list of log events.
static HRESULT clear()
Clear the log.
static bool getForwardLogging()
Test whether the logger is fowarding log events to the main Tissue Forge logger.
int32_t HRESULT
Definition tf_port.h:255
MeshLogEventType
Types of log events.
Definition tfMeshLogger.h:45