PLaSK library

Loading...
Searching...
No Matches
utils.hpp
Go to the documentation of this file.
1/*
2 * This file is part of PLaSK (https://plask.app) by Photonics Group at TUL
3 * Copyright (c) 2022 Lodz University of Technology
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, version 3.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 */
14#ifndef PLASK__MESH_UTILS_H
15#define PLASK__MESH_UTILS_H
16
17#include "mesh.hpp"
18
23 namespace plask {
24
28 struct PLASK_API SameMeshChecker {
29
30 private:
31
33 boost::signals2::connection connection_with_mesh;
34
36 const Mesh* mesh;
37
38 void setMesh(const Mesh* mesh);
39
43 void onMeshChanged(const Mesh::Event&) {
44 setMesh(nullptr);
45 }
46
47 public:
48
54 bool operator()(const Mesh* mesh) {
55 if (this->mesh == mesh)
56 return true;
57 else {
58 setMesh(mesh);
59 return false;
60 }
61 }
62
68 bool operator()(shared_ptr<const Mesh> mesh) {
69 return this->operator()(mesh.get());
70 }
71
72 /*
73 * Get mesh for which operator() has been recently called if it this @p mesh has not been changed.
74 * @return mesh for which operator() has been recently called if it this @p mesh has not been changed.
75 */
76 /*const Mesh* getMesh() const {
77 return mesh;
78 }*/
79
83 SameMeshChecker(): mesh(nullptr) {}
84
85};
86
87
88} // namespace plask
89
90#endif // PLASK__MESH_UTILS_H
91