summaryrefslogtreecommitdiffstats
path: root/src/common/common/storage.h
blob: 0e872963531a5fbb6545234118ab226493953a7d (plain)
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
/***************************************************************************
 *   Copyright (C) 2005-2006 Nicolas Hadacek <hadacek@kde.org>             *
 *                                                                         *
 *   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 STORAGE_H
#define STORAGE_H

#include "common/global/global.h"
#include <tqobject.h>

//-----------------------------------------------------------------------------
template <class Type>
class Fifo
{
public:
  Fifo() {}
  void clear() { _list.clear(); }
  uint count() const { return _list.count(); }
  void put(Type type) { _list.append(type); }
  Type get() {
    Type t = _list.first();
    _list.pop_front();
    return t;
  }

private:
  TQValueList<Type> _list;
};

//----------------------------------------------------------------------------
class GenericStorage : public TQObject
{
TQ_OBJECT
  
public:
  GenericStorage(TQObject *parent = 0, const char *name = 0) : TQObject(parent, name), _dirty(false) {}

signals:
  void changed();

protected:
  // emit changed() only after a return to the GUI loop and only one time
  void delayedChanged();

private slots:
  void changedSlot();

private:
  bool _dirty;
};

//----------------------------------------------------------------------------
class GenericView;

class GenericViewProxy : public TQObject
{
TQ_OBJECT
  
public:
  GenericViewProxy(GenericView &view) : _view(view) {}
  void addStorage(GenericStorage &storage);

private slots:
  void changed();

private:
  GenericView &_view;
};

class GenericView
{
public:
  GenericView(GenericStorage &storage);
  virtual ~GenericView() { delete _proxy; }
  virtual void updateView() = 0;

private:
  GenericViewProxy *_proxy;

  friend class GenericViewProxy;
};

#endif