My favorites | Sign in
Project Home Issues Source
Checkout   Browse   Changes    
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
/********************************************\
*
* Sire - Molecular Simulation Framework
*
* Copyright (C) 2009 Christopher Woods
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* For full details of the license please see the COPYING file
* that should have come with this distribution.
*
* You can contact the authors via the developer's mailing list
* at http://siremol.org
*
\*********************************************/

#ifndef SIREN_CLASS_H
#define SIREN_CLASS_H

#include <QSet>
#include <QStringList>

#include "object.h"

SIREN_BEGIN_HEADER

namespace Siren
{

class HanRef;

/** This class is used to provide type-information about
each of the Siren::Object derived classes

@author Christopher Woods
*/
class SIREN_EXPORT Class : public Implements<Class,Object>
{

public:
Class();

Class(const Object &object);

Class(const QString &type_name);

Class(const Class &other);

~Class();

Class& operator=(const Class &other);

bool operator==(const Class &other) const;
bool operator!=(const Class &other) const;

uint hashCode() const;

QString toString() const;

QString name() const;

bool hasSuper() const;

const Class& superClass() const;

bool implements(const QString &type_name) const;

template<class T>
bool implements() const;

QStringList interfaces() const;

ObjRef createObject() const;
HanRef createHandle() const;

bool canCreate() const;

bool isConcrete() const;

bool isObject() const;
bool isHandle() const;
bool isPrimitive() const;

bool canCast(const QString &classname) const;

void assertCanCast(const QString &classname) const;

template<class T>
bool canCast() const;

template<class T>
void assertCanCast() const;

static QStringList registeredTypes();

protected:
bool test(Logger &logger) const;
void stream(Stream &s);

private:
friend class Object; // so can call these constructors
friend class Handle; // so can call these constructors

Class(const RegisterMetaType *r);

Class(const RegisterMetaType *r,
const Class &base_class, const QStringList &interfaces);

void buildInheritedTypes();

/** Pointer to the metatype for this class */
const RegisterMetaType *metatype;

/** Pointer to this types superclass (null if this has
no superclass) */
const Class *super_class;

/** The interfaces implemented directly in this type */
QStringList interface_types;

/** The complete set of all types inherited from and
implemented in this type */
QSet<QString> inherited_types;
};

/** Return whether or not this class implements the type 'T' */
template<class T>
SIREN_OUTOFLINE_TEMPLATE
bool Class::implements() const
{
return this->implements( T::typeName() );
}

/** Return whether or not this class can be cast to type 'T' */
template<class T>
bool Class::canCast() const
{
return this->canCast( T::typeName() );
}

/** Assert that it is possible to cast this class to type 'T'

\throw Siren::invalid_cast
*/
template<class T>
void Class::assertCanCast() const
{
this->assertCanCast( T::typeName() );
}

}

Q_DECLARE_METATYPE( Siren::Class )

SIREN_EXPOSE_CLASS( Siren::Class )

SIREN_END_HEADER

#endif

Change log

r1191 by chryswoods on Feb 3, 2010   Diff
I'm debugging the new SireCluster
routines. I've also seen that typedef
super is much cleaner
than my (admittedly over-engineered)
super() functions, so I've switched the
code.

Code compiles, links, but doesn't work
properly.

Go to: 
Sign in to write a code review

Older revisions

r1108 by chryswoods on Nov 25, 2009   Diff
I've updated the metatype system so
that it works fully for Primitive and
Handle types.
Now Number and String work (and
.getClass() works for them too!)
...
r1105 by chryswoods on Nov 24, 2009   Diff
I've fixed a small bug in XMLStream -
have sorted out Mopac on HPCx (so
mopacsim.s3 contains
a QM mopac simulation that works on
AIX) and have also begun work on
...
r1101 by chryswoods on Nov 20, 2009   Diff
I've filled in most of the missing
functions in Siren - I just need to
finish off DataStream and Tester.
Once they are complete, I should be
able to link and then test Siren
...
All revisions of this file

File info

Size: 4123 bytes, 171 lines
Powered by Google Project Hosting