IMP
2.1.1
The Integrative Modeling Platform
|
Common base class for heavy weight IMP
objects.
More...
#include <IMP/base/declare_Object.h>
Inherits IMP::base::NonCopyable.
Inherited by IMP::algebra::DynamicNearestNeighbor3D, IMP::algebra::NearestNeighborD< D >, IMP::algebra::VectorKDMetric, IMP::atom::CHARMMResidueTopologyBase, IMP::atom::CHARMMSegmentTopology, IMP::atom::CHARMMTopology, IMP::atom::ForceFieldParameters, IMP::atom::Mol2Selector, IMP::atom::PDBSelector, IMP::atom::SmoothingFunction, IMP::core::ClosePairsFinder, IMP::core::DataObject< Data >, IMP::display::Geometry, IMP::display::Writer, IMP::domino::AssignmentContainer, IMP::domino::AssignmentsTable, IMP::domino::ParticleStates, IMP::domino::ParticleStatesTable, IMP::domino::RestraintCache, IMP::domino::SubsetFilter, IMP::domino::SubsetFilterTable, IMP::em2d::CollisionCrossSection, IMP::em2d::Image, IMP::em2d::ImageReaderWriter, IMP::em2d::ProjectionFinder, IMP::em2d::ScoreFunction, IMP::em::CoarseCC, IMP::em::DensityMap, IMP::em::EnvelopeScore, IMP::em::MapReaderWriter, IMP::em::PCAAligner, IMP::example::ExampleObject, IMP::isd::BivariateFunction, IMP::isd::CrossLinkData, IMP::isd::CysteineCrossLinkData, IMP::isd::FNormal, IMP::isd::FretData, IMP::isd::GaussianProcessInterpolation, IMP::isd::MultivariateFNormalSufficient, IMP::isd::UnivariateFunction, IMP::isd::vonMises, IMP::isd::vonMisesSufficient, IMP::kernel::Configuration, IMP::kernel::ConfigurationSet, IMP::kernel::Model, IMP::kernel::ModelObject, IMP::kernel::PairModifier, IMP::kernel::PairPredicate, IMP::kernel::PairScore, IMP::kernel::QuadModifier, IMP::kernel::QuadPredicate, IMP::kernel::QuadScore, IMP::kernel::Refiner, IMP::kernel::Sampler, IMP::kernel::SingletonModifier, IMP::kernel::SingletonPredicate, IMP::kernel::SingletonScore, IMP::kernel::TripletModifier, IMP::kernel::TripletPredicate, IMP::kernel::TripletScore, IMP::kernel::UnaryFunction, IMP::kernel::Undecorator, IMP::kinematics::DOF, IMP::kinematics::DOFsSampler, IMP::kinematics::Joint, IMP::kinematics::KinematicForest, IMP::kinematics::LocalPlanner, IMP::kmeans::KMeans, IMP::mpi::ReplicaExchange, IMP::multifit::AssemblyHeader, IMP::multifit::ComponentHeader, IMP::multifit::Ensemble, IMP::multifit::FFTFitting, IMP::multifit::FFTFittingOutput, IMP::multifit::ProbabilisticAnchorGraph, IMP::multifit::ProteomicsData, IMP::multifit::ProteomicsEMAlignmentAtomic, IMP::multifit::SettingsData, IMP::rmf::LoadLink, IMP::rmf::SaveLink, IMP::rotamer::RotamerCalculator, IMP::rotamer::RotamerLibrary, IMP::saxs::DerivativeCalculator, IMP::saxs::Profile, IMP::saxs::ProfileFitter< ScoringFunctionT >, IMP::statistics::Embedding, IMP::statistics::Metric, IMP::statistics::PartitionalClustering, log.DummyObject, and IMP::saxs::ProfileFitter< ChiScore >.
Public Member Functions | |
virtual void | clear_caches () |
virtual void | do_destroy () |
CheckLevel | get_check_level () const |
LogLevel | get_log_level () const |
virtual VersionInfo | get_version_info () const |
Get information about the module and version of the object. | |
void | set_check_level (CheckLevel l) |
void | set_log_level (LogLevel l) |
Set the logging level used in this object. More... | |
void | set_was_used (bool tf) const |
void | show (std::ostream &out=std::cout) const |
Protected Member Functions | |
Object (std::string name) | |
Construct an object with the given name. More... | |
Object () | |
The base class for non value-type classes in IMP
. Anything inheriting from Object has the following properties:
Types inheriting from Object should always be created using new
in C++ and passed using pointers and stored using Pointer objects. Note that you have to be careful of cycles and so must use WeakPointer objects to break cycles. IMP_NEW() can help shorten creating a ref counted pointer. See Pointer for more information.
See example::ExampleObject for a simple example.
Reference counting is a technique for managing memory and automatically freeing memory (destroying objects) when it is no longer needed. In reference counting, each object has a reference count, which tracks how many different places are using the object. When this count goes to 0, the object is freed.
Python internally refence counts everything. C++, on the other hand, requires extra steps be taken to ensure that objects are reference counted properly.
In IMP
, reference counting is done through the Pointer, PointerMember and Object classes. The former should be used instead of a raw C++ pointer when storing a pointer to any object inheriting from Object.
Any time one is using reference counting, one needs to be aware of cycles, since if, for example, object A contains an IMP::Pointer to object B and object B contains an Pointer to object A, their reference counts will never go to 0 even if both A and B are no longer used. To avoid this, use an WeakPointer in one of A or B.
Functions that create new objects should follow the following pattern
ObjectType *create_object(arguments) { IMP_NEW(ObjectType, ret, (args)); do_stuff; return ret.release(); }
using Pointer::release() to safely return the new object without freeing it.
Definition at line 123 of file base/declare_Object.h.
|
protected |
An instance of "%1%" in the string will be replaced by a unique index.
|
protected |
|
virtual |
Objects can have internal caches. This method resets them returning the object to its just-initialized state.
Reimplemented in IMP::core::ExcludedVolumeRestraint, and IMP::core::MinimumRestraint.
Definition at line 253 of file base/declare_Object.h.
|
virtual |
Overide this method to take action on destruction.
Reimplemented in IMP::display::BildWriter, IMP::display::PymolWriter, IMP::display::CMMWriter, and IMP::display::ChimeraWriter.
Definition at line 256 of file base/declare_Object.h.
void IMP::base::Object::set_check_level | ( | CheckLevel | l | ) |
Each object can be assigned a different check level too.
void IMP::base::Object::set_log_level | ( | LogLevel | l | ) |
Each object can be assigned a different log level in order to, for example, suppress messages for verbose and uninteresting objects. If set to DEFAULT, the global level as returned by IMP::get_log_level() is used, otherwise the local one is used. Methods in classes inheriting from Object should start with IMP_OBJECT_LOG to change the log level to the local one for this object and increase the current indent.
void IMP::base::Object::set_was_used | ( | bool | tf | ) | const |
IMP
provides warnings when objects are never used before they are destroyed. Examples of use include adding an IMP::Restraint to an IMP::kernel::Model. If an object is not properly marked as used, or your code is the one using it, call set_was_used(true) on the object.