/usr/include/camitk-3.2/libraries/pml/Component.h is in libcamitk3-dev 3.2.2-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 | /*****************************************************************************
* $CAMITK_LICENCE_BEGIN$
*
* CamiTK - Computer Assisted Medical Intervention ToolKit
* (c) 2001-2013 UJF-Grenoble 1, CNRS, TIMC-IMAG UMR 5525 (GMCAO)
*
* Visit http://camitk.imag.fr for more information
*
* This file is part of CamiTK.
*
* CamiTK is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* CamiTK is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with CamiTK. If not, see <http://www.gnu.org/licenses/>.
*
* $CAMITK_LICENCE_END$
****************************************************************************/
#ifndef COMPONENT_H
#define COMPONENT_H
#include "RenderingMode.h"
#include "Properties.h"
#include <string>
#include <vector>
#include <algorithm> // for remove
class Cell;
class MultiComponent;
/** A component is something that composed something and could also be
* a part of something.
*
* (just in case you don't really understand, a good reference is "The hitch
* hiker's guide to the galaxy", Douglas Adams, 1952-2001. Thanks for reading
* this absolutly clear documentation!!!)
*
*/
class Component {
public:
/** Default constructor, a component needs to know the PM it is in.
* If not given name is initialized to the empty string
*/
Component(PhysicalModel *, std::string n="");
/** Virtual destructor needed here as this is an abstract class (pure virtual) */
virtual ~Component();
/// tell if this component is exclusive or not
bool isExclusive() const;
/// set the exclusive flag
void setExclusive(const bool);
/// pure virtual method, implemented in the child-class
virtual bool isInstanceOf(const char *) const = 0;
/// get the name of the component
const std::string getName() const;
/// set the name of the component
void setName(const std::string);
/** print to an output stream in "pseudo" XML format.
*/
virtual void xmlPrint(std::ostream &) const = 0;
/// get the total nr of cell of the component
virtual unsigned int getNumberOfCells() const = 0;
/// conveniant method to get cell by order number (not cell index)
virtual Cell * getCell(unsigned int) const = 0;
/// return the state of a visibility mode
virtual bool isVisible(const RenderingMode::Mode mode) const = 0;
/// set the state of a visibility mode
virtual void setVisible(const RenderingMode::Mode mode, const bool b) = 0;
/** @name parent multi component admin
*/
/*@{*/
/// get the list of all the Multi Component that are using this Component
std::vector <MultiComponent *> getAllParentMultiComponents();
/// get the number of MultiComponent that are using this Component (= nr of parent component)
unsigned int getNumberOfParentMultiComponents() const;
/// get a particular MultiComponent that is using this Component (a particular parent component)
MultiComponent * getParentMultiComponent(unsigned int);
/// add a particular parent MultiComponent in the list
void addParentMultiComponent(MultiComponent *);
/// remove a particular parent MultiComponent
void removeParentMultiComponent(MultiComponent *);
/*@}*/
/// set the physical model
virtual void setPhysicalModel(PhysicalModel *);
/// get the physical model
PhysicalModel * getPhysicalModel() const;
/// get the component structural properties (guarantied to be non NULL)
Properties* getProperties();
protected:
Properties* properties;
/** this tell the parent components that this component is
* removed from memory.
* As the destructor is virtual, this method has to be called
* in all sub-classes destructors.
*/
void removeFromParents();
/// delete the "properties" pointer and set it to NULL
void deleteProperties();
private:
bool exclusive;
/** list of Component that are using this component
* (if another component is using this component, it is in this list)
*/
std::vector <MultiComponent *> parentMultiComponentList;
};
// -------------- inline -------------
inline void Component::setExclusive(const bool b) {
exclusive = b;
}
inline bool Component::isExclusive() const {
return exclusive;
}
inline const std::string Component::getName() const {
return properties->getName();
}
inline void Component::setName(const std::string n) {
properties->setName(n);
}
// -------------- parent Multi Component admin -------------
inline std::vector <MultiComponent *> Component::getAllParentMultiComponents() {
return parentMultiComponentList;
}
inline unsigned int Component::getNumberOfParentMultiComponents() const {
return parentMultiComponentList.size();
}
inline MultiComponent * Component::getParentMultiComponent(unsigned int i) {
if (i<parentMultiComponentList.size())
return parentMultiComponentList[i];
else
return NULL;
}
inline void Component::addParentMultiComponent(MultiComponent *c) {
parentMultiComponentList.push_back(c);
}
inline void Component::removeParentMultiComponent(MultiComponent *c) {
std::vector <MultiComponent *>::iterator it = std::find(parentMultiComponentList.begin(), parentMultiComponentList.end(), c);
if (it!=parentMultiComponentList.end())
parentMultiComponentList.erase(it);
}
inline void Component::setPhysicalModel(PhysicalModel *pm) {
properties->setPhysicalModel(pm);
}
inline PhysicalModel * Component::getPhysicalModel() const {
return properties->getPhysicalModel();
}
inline Properties* Component::getProperties() {
return properties;
}
#endif //COMPONENT_H
|