00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef __REGISTEREDTNLPS_HPP__
00010 #define __REGISTEREDTNLPS_HPP__
00011
00012 #include "IpTNLP.hpp"
00013 #include <map>
00014
00015 using namespace Ipopt;
00016
00020 class RegisteredTNLP : public TNLP
00021 {
00022 public:
00026 virtual bool InitializeProblem(Index N) = 0;
00027 };
00028
00029 class RegisteredTNLPs
00030 {
00031 public:
00032 RegisteredTNLPs(const SmartPtr<RegisteredTNLP>& tnlp, const std::string name)
00033 {
00034 RegisterTNLP(tnlp, name);
00035 }
00036 virtual ~RegisteredTNLPs()
00037 {}
00038 static SmartPtr<RegisteredTNLP> GetTNLP(const std::string name);
00039 static void PrintRegisteredProblems();
00040 private:
00041 void RegisterTNLP(const SmartPtr<RegisteredTNLP>& tnlp,
00042 const std::string name);
00043 SmartPtr<RegisteredTNLP> tnlp_;
00044 };
00045
00046 #define REGISTER_TNLP(class_constructor, name) \
00047 class RegisteredTNLP_Setup_ ## name : public RegisteredTNLPs \
00048 { \
00049 public: \
00050 RegisteredTNLP_Setup_ ## name() \
00051 : \
00052 RegisteredTNLPs(new class_constructor, #name) \
00053 { } \
00054 RegisteredTNLP_Setup_ ## name* KeepCompilerFromRemovingThis(); \
00055 }; \
00056 \
00057 RegisteredTNLP_Setup_ ## name RegisteredTNLP_Setup_ ## name ## instance_; \
00058 RegisteredTNLP_Setup_ ## name* \
00059 RegisteredTNLP_Setup_ ## name::KeepCompilerFromRemovingThis() \
00060 { return &RegisteredTNLP_Setup_ ## name ## instance_; }
00061
00062
00063
00064 #endif