abstract types used in device/resource system
[quarnos.git] / manes / type_name.cpp
blobefebaca5a86c48130129473400326ff2c28f0681
1 /* Quarn OS / Manes
3 * Type name class
5 * Copyright (C) 2008-2009 Pawel Dziepak
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 #include "type_name.h"
24 #include "manec.h"
26 using namespace manes;
28 unsigned int manes::type_name::last_tid = 0;
30 type_name::type_name(const string &_name, const int newtype) :
31 /*type_id(last_tid++),*/
32 text_name(_name),
33 last_tcid(0) {
34 assert("type_name: creation of new type_name with no string", _name.null());
37 type_name::type_name(const string _name, const bool newtype) :
38 /*type_id(last_tid++),*/
39 text_name(_name),
40 last_tcid(0) {
41 assert("type_name: creation of new type_name with no string", _name.null());
44 type_name::type_name(const string _name) : text_name(_name), last_tcid(0) {
45 type_id = 0;
46 //type_id = manec::get()->get_type(*this)->get_name().get_id();
49 type_name::type_name(){}
50 //type_name::type_name(int){}
51 type_name::type_name(const type_name &x) :
52 /*type_id(last_tid++),*/
53 text_name(x.text_name),
54 last_tcid(x.last_tcid) {
58 unsigned int type_name::get_tcid() const {
59 unsigned int tcid = last_tcid++;
61 assert("type_name: last_tcid overflow!", last_tcid == 0);
63 return tcid;
66 unsigned int type_name::get_id() const {
67 return type_id;
70 string type_name::get_textname() const {
71 return text_name;
74 bool type_name::operator==(const type_name &x) const {
75 /*if (x.type_id == type_id && type_id && x.type_id)
76 return true;*/
77 if (x.text_name == text_name /*&& !type_id && !x.type_id*/)
78 return true;
79 return false;
82 bool type_name::operator==(const unsigned int x) const {
83 return x == type_id;