Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 11750


Ignore:
Timestamp:
Feb 15, 2018, 11:18:38 PM (7 years ago)
Author:
landauf
Message:

[Dialog_HS17] cleanup XMLPort collection getters

Location:
code/branches/Presentation_HS17_merge/src/modules/dialog
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • code/branches/Presentation_HS17_merge/src/modules/dialog/Dialog.cc

    r11749 r11750  
    8989        }
    9090
    91         const Question* Dialog::getQuestion() const // returned nichts
     91        Question* Dialog::getQuestion(unsigned int index) const
    9292        {
    93                 return nullptr;
     93        unsigned int i = 0;
     94        for (auto entry : this->questions_)
     95        {
     96            if (i == index)
     97                return entry.second;
     98            ++i;
     99        }
     100        return nullptr;
    94101        }
    95102
     
    99106        }
    100107
    101         const Answer* Dialog::getAnswer(unsigned int index) const       //returned sting der Antwort zur Id.
     108        Answer* Dialog::getAnswer(unsigned int index) const
    102109        {
    103                 return nullptr;
     110        unsigned int i = 0;
     111        for (auto entry : this->answers_)
     112        {
     113            if (i == index)
     114                return entry.second;
     115            ++i;
     116        }
     117        return nullptr;
    104118        }
    105119
    106120
    107         const std::vector<std::string>* Dialog::getAnswerIds() // returned vector mit allen momentanen AntwortenIds
     121        const std::vector<std::string>& Dialog::getAnswerIds() const // returned vector mit allen momentanen AntwortenIds
    108122        {
    109123               
    110124                Question* question = (this->questions_.find(this->currentQuestionId_))->second;
    111                 const std::vector<std::string>* answers = question->getAnswerIds();
    112                 return answers;
     125                return question->getAnswerIds();
    113126               
    114127        }
     
    145158        }
    146159
    147         const std::string& Dialog::getAnswerString(std::string answerId)
     160        const std::string& Dialog::getAnswerString(const std::string& answerId)
    148161        {
    149162                return this->answers_.find(answerId)->second->getAnswer();
  • code/branches/Presentation_HS17_merge/src/modules/dialog/Dialog.h

    r11749 r11750  
    6868
    6969                        void addQuestion(Question* question); //xmlPort-Funktion, adds question to map
    70                         const Question* getQuestion() const; //xmlPort-Funktion, returns nullptr
     70                        Question* getQuestion(unsigned int index) const; //xmlPort-Funktion
    7171
    7272                        void addAnswer(Answer* answer); //xmlPort-Funktion, adds answer to map
    73                         const Answer* getAnswer(unsigned int index) const; //xmlPort-Funktion, returns nullptr
     73                        Answer* getAnswer(unsigned int index) const; //xmlPort-Funktion
    7474
    7575                        /**
     
    8080                    pointer to answerId array of question
    8181                */
    82                         const std::vector<std::string>* getAnswerIds();
     82                        const std::vector<std::string>& getAnswerIds() const;
    8383
    8484                        /**
     
    133133                        sting with answer
    134134                */
    135                         const std::string& getAnswerString(std::string answerId);
     135                        const std::string& getAnswerString(const std::string& answerId);
    136136
    137137                private:
  • code/branches/Presentation_HS17_merge/src/modules/dialog/DialogManager.cc

    r11749 r11750  
    4545        {
    4646                this->currentTalk_ = dialog;
    47                 answerIds_ = currentTalk_->getAnswerIds();     
     47                answerIds_ = &currentTalk_->getAnswerIds();
    4848        }
    4949
     
    8686    {
    8787        this->currentTalk_->update(answerIds_->at(index));
    88         answerIds_ = this->currentTalk_->getAnswerIds();
     88        answerIds_ = &this->currentTalk_->getAnswerIds();
    8989    }
    9090}
  • code/branches/Presentation_HS17_merge/src/modules/dialog/Question.cc

    r11749 r11750  
    7575        }
    7676
    77         const AnswerId* Question::getAnswerId() const
     77        AnswerId* Question::getAnswerId(unsigned int index) const
    7878        {
    7979                return nullptr;
    8080        }
    8181
    82         const std::vector<std::string>* Question::getAnswerIds()
     82        const std::vector<std::string>& Question::getAnswerIds() const
    8383        {
    84                 return &(this->answerIds_);
     84                return this->answerIds_;
    8585        }
    8686       
  • code/branches/Presentation_HS17_merge/src/modules/dialog/Question.h

    r11749 r11750  
    6363
    6464                        void addAnswerId(AnswerId* answerId);   //xmlPort-Funktion, nimmt AnswerIds von entsprechenden Objekten und fuegt sie in List ein.
    65                         const AnswerId* getAnswerId() const;    //xmlPort-Funktion, gibt nichts zuruek
     65                        AnswerId* getAnswerId(unsigned int index) const;        //xmlPort-Funktion, gibt nichts zuruek
    6666
    6767                        /**
     
    7272                        returns pointer to the array with ids of possible pc textoptions
    7373                */
    74                         const std::vector<std::string>* getAnswerIds(); //returnt Pointer auf Vektor mit allen Ids
     74                        const std::vector<std::string>& getAnswerIds() const; //returnt Pointer auf Vektor mit allen Ids
    7575
    7676
Note: See TracChangeset for help on using the changeset viewer.