Index: kernel/include/exception.h =================================================================== --- kernel/include/exception.h (revision 916) +++ kernel/include/exception.h (working copy) @@ -143,9 +143,6 @@ #define IMP_IF_CHECK(level)\ if (level <= ::IMP::get_check_level()) -namespace internal -{ - //! This is just here so you can catch errors more easily in the debugger /** Break on exception.cpp:31 to catch assertion failures. \ingroup assert @@ -158,8 +155,6 @@ */ IMPDLLEXPORT void check_fail(const char *msg); -} // namespace internal - #ifndef NDEBUG //! An assertion for IMP. An IMP::ErrorException will be thrown. @@ -178,7 +173,7 @@ oss << message << std::endl \ << " File \"" << __FILE__ << "\", line " << __LINE__ \ << std::endl; \ - IMP::internal::assert_fail(oss.str().c_str()); \ + IMP::assert_fail(oss.str().c_str()); \ } \ } while(false) #else @@ -197,7 +192,7 @@ if (IMP::get_check_level() >= IMP::CHEAP && !(expr)) { \ std::ostringstream oss; \ oss << message << std::endl; \ - IMP::internal::check_fail(oss.str().c_str()); \ + IMP::check_fail(oss.str().c_str()); \ throw ExceptionType(oss.str().c_str()); \ } \ } while (false) @@ -211,7 +206,7 @@ #define IMP_failure(message, ExceptionType) { \ std::ostringstream oss; \ oss << message << std::endl; \ - IMP::internal::check_fail(oss.str().c_str()); \ + IMP::check_fail(oss.str().c_str()); \ throw ExceptionType(oss.str().c_str());} IMP_END_NAMESPACE Index: kernel/include/Particle.h =================================================================== --- kernel/include/Particle.h (revision 916) +++ kernel/include/Particle.h (working copy) @@ -22,20 +22,6 @@ IMP_BEGIN_NAMESPACE -namespace internal -{ - -template -void check_particles_active(It b, It e, std::string msg) -{ - for (It c= b; c != e; ++c) { - IMP_check((*c)->get_is_active(), msg, - InactiveParticleException); - } -} - -} // namespace internal - class Model; //! Class to handle individual model particles. Index: kernel/include/IMP_config.h =================================================================== --- kernel/include/IMP_config.h (revision 916) +++ kernel/include/IMP_config.h (working copy) @@ -34,4 +34,14 @@ #define IMP_END_NAMESPACE \ } /* namespace IMP */ +#define IMP_BEGIN_INTERNAL_NAMESPACE \ +IMP_BEGIN_NAMESPACE \ +namespace internal \ +{ + +#define IMP_END_INTERNAL_NAMESPACE \ +} /* namespace internal */ \ +IMP_END_NAMESPACE + + #endif /* IMP_CONFIG_H */ Index: kernel/include/internal/key_helpers.h =================================================================== --- kernel/include/internal/key_helpers.h (revision 0) +++ kernel/include/internal/key_helpers.h (revision 0) @@ -0,0 +1,45 @@ +/** + * \file key_helpers.h \brief helpers for declaring keys. + * + * Copyright 2007-8 Sali Lab. All rights reserved. + * + */ + +#ifndef IMP_INTERNAL_KEY_HELPERS_H +#define IMP_INTERNAL_KEY_HELPERS_H + +#include "../IMP_config.h" +#include + +IMP_BEGIN_INTERNAL_NAMESPACE +/** \internal The data concerning keys. + */ +struct IMPDLLEXPORT KeyData +{ + typedef std::map Map; + typedef std::vector RMap; + + void show(std::ostream &out= std::cout) const; + KeyData(); + void assert_is_initialized() const; + unsigned int add_key(std::string str) { + unsigned int i= map_.size(); + map_[str]=i; + rmap_.push_back(str); + return i; + } + + const Map &get_map() const {return map_;} + const RMap &get_rmap() const {return rmap_;} + +private: + double heuristic_; + Map map_; + RMap rmap_; +}; + +IMPDLLEXPORT extern std::map key_data; + +IMP_END_INTERNAL_NAMESPACE + +#endif /* IMP_INTERNAL_KEY_HELPERS_H */ \ No newline at end of file Index: kernel/include/internal/SConscript =================================================================== --- kernel/include/internal/SConscript (revision 916) +++ kernel/include/internal/SConscript (working copy) @@ -1,7 +1,7 @@ files = ['AttributeTable.h', 'Vector.h', 'ref_counting.h', 'ObjectContainer.h', 'kernel_version_info.h', 'constants.h', 'units.h', - 'utility.h', 'Unit.h', 'ExponentialNumber.h'] + 'utility.h', 'Unit.h', 'ExponentialNumber.h', 'key_helpers.h'] files = [File(f) for f in files] Return('files') Index: kernel/include/Key.h =================================================================== --- kernel/include/Key.h (revision 916) +++ kernel/include/Key.h (working copy) @@ -10,6 +10,7 @@ #include "macros.h" #include "exception.h" +#include "internal/key_helpers.h" #include #include @@ -63,42 +64,7 @@ }; \ typedef std::vector Name##s -namespace internal -{ - -/** \internal The data concerning keys. - */ -struct IMPDLLEXPORT KeyData -{ - typedef std::map Map; - typedef std::vector RMap; - - void show(std::ostream &out= std::cout) const; - KeyData(); - void assert_is_initialized() const; - unsigned int add_key(std::string str) { - unsigned int i= map_.size(); - map_[str]=i; - rmap_.push_back(str); - return i; - } - - const Map &get_map() const {return map_;} - const RMap &get_rmap() const {return rmap_;} - -private: - double heuristic_; - Map map_; - RMap rmap_; -}; - -IMPDLLEXPORT extern std::map key_data; - -} // namespace internal - - - //! A base class for Keys /** This class does internal caching of the strings to accelerate the name lookup. It is better to create an Key and reuse it Index: kernel/src/exception.cpp =================================================================== --- kernel/src/exception.cpp (revision 916) +++ kernel/src/exception.cpp (working copy) @@ -51,12 +51,15 @@ { } -namespace internal +namespace { // The error message is already in the exception bool print_exceptions=false; + +} + void assert_fail(const char *msg) { if (print_exceptions) { @@ -72,6 +75,4 @@ } } -} // namespace internal - IMP_END_NAMESPACE