Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/questsystem/src/orxonox/objects/QuestItem.cc @ 2081

Last change on this file since 2081 was 2081, checked in by dafrick, 16 years ago

Ready for merge! (It won't compile after the merge, though ;) )

File size: 2.8 KB
Line 
1/*
2 *   ORXONOX - the hottest 3D action shooter ever to exist
3 *                    > www.orxonox.net <
4 *
5 *
6 *   License notice:
7 *
8 *   This program is free software; you can redistribute it and/or
9 *   modify it under the terms of the GNU General Public License
10 *   as published by the Free Software Foundation; either version 2
11 *   of the License, or (at your option) any later version.
12 *
13 *   This program is distributed in the hope that it will be useful,
14 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
15 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 *   GNU General Public License for more details.
17 *
18 *   You should have received a copy of the GNU General Public License
19 *   along with this program; if not, write to the Free Software
20 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21 *
22 *   Author:
23 *      Damian 'Mozork' Frick
24 *   Co-authors:
25 *      ...
26 *
27 */
28
29#include "core/CoreIncludes.h"
30
31#include "QuestItem.h"
32
33namespace orxonox {
34   
35    QuestItem::QuestItem() : BaseObject()
36    {
37        this->initialize();
38    }
39   
40    /**
41    @brief
42        Destructor.
43    */
44    QuestItem::~QuestItem()
45    {
46       
47    }
48   
49    void QuestItem::XMLPort(Element& xmlelement, XMLPort::Mode mode)
50    {
51        SUPER(QuestItem, XMLPort, xmlelement, mode);
52       
53        XMLPortParam(QuestItem, "id", setId, getId, xmlelement, mode);
54        //Doesn't getDescription have to be of type getDescription(unsigned int) ?
55        //XMLPortObjectTemplate(QuestItem, QuestDescription, "", setDescription, getDescription, xmlelement, mode, unsigned int);
56        XMLPortObject(QuestItem, QuestDescription, "", setDescription, getDescription, xmlelement, mode);
57
58    }
59
60   
61    /**
62    @brief
63        Initializes the object.
64        Should be called first in every constructor of this class.
65    */
66    void QuestItem::initialize(void)
67    {
68        RegisterObject(QuestItem);
69       
70        this->id_ = "";
71    }
72   
73    void QuestItem::setId(const std::string & id)
74    {
75        if(!isId(id))
76        {
77            COUT(2) << "Invalid id. QuestItem id {" << id << "} could not be set." << std::endl;
78            return;
79        }
80        this->id_ = id;
81    }
82   
83    //const QuestDescription* QuestItem::getDescription(unsigned int index) const //!< Returns the description of the QuestItem.
84    //{
85    //    if(index != 0)
86    //        return NULL;
87    //    return this->description_;
88    //}
89   
90    /**
91    @brief
92        Checks whether an input id is of the required form.
93    @param id
94        The id to be checked.
95    @return
96        Returns true if the string is likely to be of the required form.
97    @todo
98        Clarify form, more vigorous checks.
99    */
100    bool QuestItem::isId(const std::string & id)
101    {
102        return id.size() >= 32;
103    }
104
105}
Note: See TracBrowser for help on using the repository browser.