~kst-plot/kst/debian-xenial

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
/***************************************************************************
                 object.h: abstract base class for all Kst objects
                             -------------------
    begin                : May 22, 2003
    copyright            : (C) 2003 The University of Toronto
    email                : netterfield@astro.utoronto.ca
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   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.                                   *
 *                                                                         *
 ***************************************************************************/

#ifndef OBJECT_H
#define OBJECT_H

#include <QPointer>
#include <QMutex>
#include <QObject>
#include <QString>
#include <QDebug>
#include <QStringList>
#include <QMetaType>
#include <QXmlStreamWriter>

#include "namedobject.h"
#include "kst_export.h"
#include "sharedptr.h"
#include "rwlock.h"

namespace Kst {

class ObjectStore;
class Object;

typedef SharedPtr<Object> ObjectPtr;


class KSTCORE_EXPORT Object : public QObject, public Shared, public KstRWLock, public NamedObject 
{
    Q_OBJECT

  public:
    static QString type();
    static const qint64 Forced = -1;
    static const qint64 NoInputs = -2;

    enum UpdateType { NoChange = 0, Updated, Deferred };

    virtual UpdateType objectUpdate(qint64 newSerial);
    virtual void registerChange() {_serial = Forced; emit dirty();}

    virtual void reset();

    qint64 serial() const {return _serial;}
    qint64 serialOfLastChange() const {return _serialOfLastChange;}

    virtual const QString& typeString() const;
    static const QString staticTypeString;

    ObjectStore *store() const;

    // Returns count - 2 to account for "this" and the list pointer, therefore
    // you MUST have a reference-counted pointer to call this function
    virtual int getUsage() const;

    virtual void deleteDependents();

    virtual void internalUpdate() = 0;

    virtual bool used() const {return _used;}
    virtual void setUsed(bool used_in) {_used = used_in;}

    virtual bool uses(ObjectPtr p) const;

  protected:
    Object();
    virtual ~Object();

    friend class ObjectStore;
    ObjectStore *_store;  // set by ObjectStore

    virtual qint64 minInputSerial() const = 0;
    virtual qint64 maxInputSerialOfLastChange() const = 0;

    qint64 _serial;
    qint64 _serialOfLastChange;
    bool _used;
  signals:
    void dirty();
  };


}

Q_DECLARE_METATYPE(Kst::Object*)

#endif

// vim: ts=2 sw=2 et