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
/********************************************\
*
* 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_OBJREF_H
#define SIREN_OBJREF_H

#include "object.h"
#include "detail/sharedpolypointer.hpp"

SIREN_BEGIN_HEADER

namespace Siren
{
class ObjRef;
class Stream;

template<class T> class ObjPtr;
}

namespace Siren
{

namespace detail
{
template<class T> struct StreamHelper;
}

Object* extractPointer(ObjRef &objref);

/** This is a light-weight reference to an object. This class is
used when a new object is returned from a function. This class
will automatically cast itself back into a real const Object&
reference
*/
class SIREN_EXPORT ObjRef
{
public:
ObjRef();
ObjRef(const Object &obj);
ObjRef(Object *obj);

template<class T>
ObjRef(const ObjPtr<T> &ptr);

ObjRef(const ObjRef &other);

~ObjRef();

ObjRef& operator=(const ObjRef &other);
ObjRef& operator=(const Object &other);

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

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

Class getClass() const;

static QString typeName();

QString what() const;

ObjRef clone() const;

bool unique() const;
bool isNone() const;

QString toString() const;

bool test() const;
bool test(Logger &logger) const;

void copy(const Object &other);

bool equals(const Object &other) const;

void save(Stream &s) const;
void load(Stream &s);

void stream(Stream &s);

uint hashCode() const;

template<class T>
bool isA() const;

template<class T>
const T& asA() const;

const Object& operator*() const;

operator const Object&() const;

private:
friend class detail::StreamHelper<ObjRef>;

friend Object* extractPointer(ObjRef &objref);

/** The shared pointer to the actual object */
detail::SharedPolyPointer<Object> d;
};

#ifndef SIREN_SKIP_INLINE_FUNCTIONS

template<class T>
SIREN_OUTOFLINE_TEMPLATE
ObjRef::ObjRef( const ObjPtr<T> &ptr )
{
if (not ptr.isNull())
this->operator=( *ptr );
}

/** Return whether or not this object is an object of type 'T' */
template<class T>
SIREN_INLINE_TEMPLATE
bool ObjRef::isA() const
{
return d->isA<T>();
}

/** Cast this object to type 'T'. This raises a Siren::invalid_cast
exception if this cast is not possible

\throw Siren::invalid_cast
*/
template<class T>
SIREN_INLINE_TEMPLATE
const T& ObjRef::asA() const
{
return d->asA<T>();
}

#endif // SIREN_SKIP_INLINE_FUNCTIONS

}

SIREN_EXPOSE_CLASS( Siren::ObjRef )

SIREN_END_HEADER

#endif

Change log

r1128 by chryswoods on Dec 8, 2009   Diff
I've fixed the automatic conversion of
ObjRef and ObjPtr to PyObject, so that
clone_const_reference and automatic
conversion of ObjPtr derived types works.
Python wrappers for SireMaths and SireBase
seem to compile and work well.

Code is still quite broken

Go to: 
Sign in to write a code review

Older revisions

r1126 by chryswoods on Dec 6, 2009   Diff
SireBase and SireMaths now both
compile and link and the tests (those
that have been written)
run via sirentest.

...
r1125 by chryswoods on Dec 6, 2009   Diff
I've nearly finished porting SireBase
over to Siren. I've just got to
finish Properties, CombineProperties
and LinkToProperty.

...
r1121 by chryswoods on Dec 2, 2009   Diff
Sire (and Siren) now compile and work
on HPCx, with parallel jobs working
without problem.
The only difficulty now is that there
are QBuffer memory errors which are
...
All revisions of this file

File info

Size: 3775 bytes, 167 lines
Powered by Google Project Hosting