00001 /** 00002 * \file OptimizerState.h \brief Shared optimizer state. 00003 * 00004 * Copyright 2007-2010 IMP Inventors. All rights reserved. 00005 * 00006 */ 00007 00008 #ifndef IMP_OPTIMIZER_STATE_H 00009 #define IMP_OPTIMIZER_STATE_H 00010 00011 #include "kernel_config.h" 00012 #include "VersionInfo.h" 00013 #include "RefCounted.h" 00014 #include "Pointer.h" 00015 #include "VectorOfRefCounted.h" 00016 00017 #include <iostream> 00018 00019 IMP_BEGIN_NAMESPACE 00020 00021 class Optimizer; 00022 00023 //! Shared optimizer state. 00024 /** The OptimizerState update method is called each time the Optimizer commits 00025 to a new set of coordinates. Optimizer states may change the values of 00026 particle attributes. However, changes to whether an attribute is optimized 00027 or not may not be picked up by the Optimizer until the next call to 00028 optimize. 00029 00030 \note When logging is VERBOSE, state should print enough information 00031 in evaluate to reproduce the the entire flow of data in update. When 00032 logging is TERSE the restraint should print out only a constant number 00033 of lines per update call. 00034 00035 Implementors should see IMP_OPTIMIZER_STATE(). 00036 */ 00037 class IMPEXPORT OptimizerState : public Object 00038 { 00039 friend class Optimizer; 00040 void set_optimizer(Optimizer* optimizer); 00041 00042 public: 00043 OptimizerState(std::string name="OptimizerState %1%"); 00044 00045 //! Called when the Optimizer accepts a new conformation 00046 virtual void update() = 0; 00047 00048 Optimizer *get_optimizer() const { 00049 IMP_INTERNAL_CHECK(optimizer_, 00050 "Must call set_optimizer before get_optimizer on state"); 00051 return optimizer_.get(); 00052 } 00053 IMP_REF_COUNTED_DESTRUCTOR(OptimizerState); 00054 protected: 00055 WeakPointer<Optimizer> optimizer_; 00056 }; 00057 00058 IMP_OBJECTS(OptimizerState); 00059 /** \objects{OptimizerState} 00060 */ 00061 /** \objectstemp{OptimizerState} 00062 */ 00063 IMP_END_NAMESPACE 00064 00065 #endif /* IMP_OPTIMIZER_STATE_H */