9 #ifndef IMPKERNEL_OBJECT_H
10 #define IMPKERNEL_OBJECT_H
12 #include <IMP/kernel_config.h>
13 #include <IMP/kernel_config.h>
26 #include <boost/scoped_array.hpp>
28 #if !defined(IMP_HAS_CHECKS)
29 #error "IMP_HAS_CHECKS not defined, something is broken"
31 #if !defined(IMP_NONE)
32 #error "IMP_NONE not defined, something is broken"
34 #if !defined(IMP_HAS_LOG)
35 #error "IMP_HAS_LOG not defined, something is broken"
37 #if !defined(IMP_SILENT)
38 #error "IMP_SILENT not defined, something is broken"
41 IMPKERNEL_BEGIN_NAMESPACE
108 boost::scoped_array<char> quoted_name_;
110 static unsigned int live_objects_;
113 #if IMP_HAS_LOG != IMP_NONE
117 #if IMP_HAS_CHECKS >= IMP_USAGE
119 mutable bool was_owned_;
123 #if IMP_HAS_CHECKS >= IMP_INTERNAL
124 static void add_live_object(
Object* o);
125 static void remove_live_object(
Object* o);
128 void initialize(std::string name);
184 const std::string& get_name()
const {
return name_; }
185 void set_name(std::string name);
186 virtual std::string get_type_name()
const {
return "unknown object type"; }
194 void set_was_used(
bool tf)
const;
200 std::string get_string()
const {
201 std::ostringstream oss;
207 void ref()
const { ++count_; }
209 void release()
const;
210 const char* get_quoted_name_c_string()
const {
return quoted_name_.get(); }
213 void _on_destruction();
216 bool get_is_valid()
const;
218 unsigned int get_ref_count()
const {
return count_; }
220 static unsigned int get_number_of_live_objects() {
return live_objects_; }
221 bool get_is_shared()
const {
return count_ > 1; }
222 #endif // IMP_DOXYGEN
234 #if !defined(SWIG) && !defined(IMP_DOXYGEN)
236 IMP_CHECK_VARIABLE(l);
237 #if IMP_HAS_CHECKS != IMP_NONE
243 #if IMP_HAS_LOG == IMP_SILENT
250 #if IMP_HAS_CHECKS == IMP_NONE
257 inline void Object::set_was_used(
bool tf)
const {
258 IMP_CHECK_VARIABLE(tf);
259 #if IMP_HAS_CHECKS >= IMP_USAGE
264 inline bool Object::get_is_valid()
const {
265 #if IMP_HAS_CHECKS == IMP_NONE
268 return static_cast<int>(check_value_) == 111111111;
273 #if !defined(IMP_DOXYGEN) && !defined(SWIG)
279 ShowFull(Object* o) {
280 std::ostringstream oss;
284 const std::string& get_string()
const {
return showed_; }
286 inline std::ostream& operator<<(std::ostream& o,
const ShowFull& sf) {
287 o << sf.get_string();
291 IMPKERNEL_END_NAMESPACE
Macros to help with reference counting.
CheckLevel get_check_level()
Get the current audit mode.
Base class for all objects that cannot be copied.
#define IMP_HASHABLE_INLINE(name, hashret)
Helper functions for implementing hashes.
LogLevel
The log levels supported by IMP.
#define IMP_SHOWABLE(Name)
virtual void clear_caches()
Exception definitions and assertions.
LogLevel get_log_level()
Get the currently active global log level.
Base class for all objects that cannot be copied.
virtual void do_destroy()
Common base class for heavy weight IMP objects.
Macros to control compiler warnings.
int compare(const VectorD< D > &a, const VectorD< D > &b)
lexicographic comparison of two vectors
Helper macros for implementing hashable classes.
Various general useful macros for IMP.
Version and module information for Objects.
Basic enumeration types used by IMP.
std::ostream & show(Hierarchy h, std::ostream &out=std::cout)
Print the hierarchy using a given decorator to display each node.
void set_log_level(LogLevel l)
Set the current global log level.
CheckLevel
Specify the level of runtime checks performed.
virtual VersionInfo get_version_info() const
Get information about the module and version of the object.
Version and authorship of IMP objects.
Macros to help with objects that can be printed to a stream.
void set_check_level(CheckLevel tf)
Control runtime checks in the code.