Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/orxonox/objects/quest/QuestItem.cc @ 2093

Last change on this file since 2093 was 2093, checked in by landauf, 16 years ago

converted tabs to spaces

  • Property svn:eol-style set to native
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* creator) : BaseObject(creator)
36    {
37        RegisterObject(QuestItem);
38
39        this->initialize();
40    }
41
42    /**
43    @brief
44        Destructor.
45    */
46    QuestItem::~QuestItem()
47    {
48
49    }
50
51    void QuestItem::XMLPort(Element& xmlelement, XMLPort::Mode mode)
52    {
53        SUPER(QuestItem, XMLPort, xmlelement, mode);
54
55        XMLPortParam(QuestItem, "id", setId, getId, xmlelement, mode);
56        //Doesn't getDescription have to be of type getDescription(unsigned int) ?
57        //XMLPortObjectTemplate(QuestItem, QuestDescription, "", setDescription, getDescription, xmlelement, mode, unsigned int);
58        XMLPortObject(QuestItem, QuestDescription, "", setDescription, getDescription, xmlelement, mode);
59
60    }
61
62
63    /**
64    @brief
65        Initializes the object.
66        Should be called first in every constructor of this class.
67    */
68    void QuestItem::initialize(void)
69    {
70        RegisterObject(QuestItem);
71
72        this->id_ = "";
73    }
74
75    void QuestItem::setId(const std::string & id)
76    {
77        if(!isId(id))
78        {
79            COUT(2) << "Invalid id. QuestItem id {" << id << "} could not be set." << std::endl;
80            return;
81        }
82        this->id_ = id;
83    }
84
85    //const QuestDescription* QuestItem::getDescription(unsigned int index) const //!< Returns the description of the QuestItem.
86    //{
87    //    if(index != 0)
88    //        return NULL;
89    //    return this->description_;
90    //}
91
92    /**
93    @brief
94        Checks whether an input id is of the required form.
95    @param id
96        The id to be checked.
97    @return
98        Returns true if the string is likely to be of the required form.
99    @todo
100        Clarify form, more vigorous checks.
101    */
102    bool QuestItem::isId(const std::string & id)
103    {
104        return id.size() >= 32;
105    }
106
107}
Note: See TracBrowser for help on using the repository browser.