Ignore:
Timestamp:
Jan 13, 2010, 10:22:29 AM (16 years ago)
Author:
Tillmann Crueger <crueger@…>
Children:
3896fc
Parents:
c489d9
Message:

Changed dialog structure to use objects for queries.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • molecuilder/src/UIElements/Dialog.hpp

    rc489d9 rf89c1c  
    1212#include<list>
    1313
     14class MoleculeListClass;
     15class Molecule;
     16
    1417class Dialog
    1518{
     
    1821  virtual ~Dialog();
    1922
    20   void queryInt(const char *, int *);
    21   void queryString(const char*, std::string *);
     23  virtual void queryInt(const char *, int *)=0;
     24  virtual void queryString(const char*, std::string *)=0;
     25 // virtual void queryMolecule(const char*,MoleculeListClass*,Molecule*)=0;
    2226
    23   virtual void display();
     27  virtual bool display();
    2428
    2529protected:
    26   virtual void handleInt(std::string,int *)=0;
    27   virtual void handleString(std::string,std::string *)=0;
    28 
    29 
    30 private:
    3130  // methodology for handling queries
    3231  // all queries are stored and then performed at appropriate times
    3332
    3433  //these queries can be handled by this dialog
    35   enum QueryType {Int,String};
    36   struct Query {
     34
     35  //TODO: Find a way to reduce complexity...
     36  //needs O(N*M) query classes, where N is the number of query types and M is the number of GUIs
     37  //usual approach for reducing inheritance complexity (strategy pattern) does not work,
     38  //due to lack of common code for query types as well as GUI-Types (all subtypes differ a lot)
     39
     40  //base class for all queries
     41  class Query {
     42  public:
     43    Query(std::string _title);
     44    ~Query();
     45    virtual bool handle()=0;
     46    virtual void setResult()=0;
     47  protected:
     48    const std::string getTitle() const;
     49  private:
    3750    std::string title;
    38     QueryType type;
    39     void *target;
    4051  };
    4152
    42   std::list<Query> queries;
     53  //Specialized classes for certain types. GUI-Types are not specialized at this time
     54  class IntQuery : public Query {
     55  public:
     56    IntQuery(std::string title,int *_target);
     57    ~IntQuery();
     58    virtual bool handle()=0;
     59    virtual void setResult();
     60  protected:
     61    int tmp;
     62  private:
     63    int *target;
     64  };
     65
     66  class StringQuery : public Query {
     67  public:
     68    StringQuery(std::string title,std::string *_target);
     69    ~StringQuery();
     70    virtual bool handle()=0;
     71    virtual void setResult();
     72  protected:
     73    std::string tmp;
     74  private:
     75    std::string *target;
     76  };
     77
     78void registerQuery(Query* query);
     79
     80private:
     81  std::list<Query*> queries;
    4382
    4483};
Note: See TracChangeset for help on using the changeset viewer.