GeneticOperatorControl.h

00001 
00004 #ifndef _GeneticOperatorControl_h
00005 #define _GeneticOperatorControl_h
00006 
00007 // SYSTEM INCLUDES
00008 //
00009 
00010 // PROJECT INCLUDES
00011 //
00012 
00013 // LOCAL INCLUDES
00014 //
00015 #include "ObjectChoice.h"
00016 
00017 // FORWARD REFERENCES
00018 //
00019 
00020 template <class T>
00021 class GeneticOperatorControl
00022     : public wxPanel
00023 {
00024 public:
00025 // LIFECYCLE
00026 
00029     GeneticOperatorControl(wxWindow*        pParent,
00030                            wxWindowID       id,
00031                            const wxPoint&   pos = wxDefaultPosition,
00032                            const wxSize&    size = wxDefaultSize,
00033                            long             style = 0)
00034         : wxPanel(pParent, id, pos, size, wxTAB_TRAVERSAL)
00035     {
00036         wxSizer* p_sizer_main = new wxStaticBoxSizer(wxVERTICAL,
00037                                                      this,
00038                                                      T::BaseClassName());
00039 
00040         mpOperatorChoice = new ObjectChoice<T>(this, -1);
00041         p_sizer_main->Add(mpOperatorChoice, 0, wxALL|wxEXPAND, 2);
00042 
00043         SetAutoLayout(true);
00044         SetSizer(p_sizer_main);
00045         p_sizer_main->Fit(this);
00046         p_sizer_main->SetSizeHints(this);
00047 
00048         Layout();
00049     }
00050 
00053     ~GeneticOperatorControl(void)
00054     {
00055     }
00056 
00057 // OPERATORS
00058 // OPERATIONS
00059 
00062     void        Insert(CountedPtr<T> cpOperator)
00063     {
00064         const wxString& name = cpOperator->Name();
00065 
00066         mpOperatorChoice->Insert(name, cpOperator);
00067     }// Insert
00068 
00071     void        SetList(const std::vector<T*>& operatorsContainer)
00072     {
00073         CountedPtr<T>                   cp_operator;
00074         typename std::vector<T*>::const_iterator iter;
00075 
00076         for (iter = operatorsContainer.begin();
00077              iter != operatorsContainer.end();
00078              iter++)
00079         {
00080             cp_operator.Reset(((*iter)->Clone()).release());
00081             const wxString& name = cp_operator->Name();
00082             mpOperatorChoice->Insert(name, cp_operator);
00083         }
00084     }
00085 
00090     std::auto_ptr<T>    CreateSelected()
00091     {
00092         return mpOperatorChoice->GetSelected()->Clone();
00093     }// CreateSelected
00094 
00100     int         SelectName(const wxString& name)
00101     {
00102         int position = mpOperatorChoice->FindString(name);
00103 
00104         if (position != wxNOT_FOUND)
00105                 mpOperatorChoice->SetSelection(position);
00106 
00107         return position;
00108     }// SelectName
00109 
00110 // ACCESS
00111 // INQUIRY
00112 
00113 protected:
00114 private:
00115 
00116     ObjectChoice<T>*  mpOperatorChoice;
00117 
00118 };
00119 
00120 // INLINE METHODS
00121 //
00122 
00123 // EXTERNAL REFERENCES
00124 //
00125 
00126 #endif  // _GeneticOperatorControl_h

Wygenerowano Fri Sep 29 21:04:48 2006 dla EduOptim2 programem  doxygen 1.4.6