summaryrefslogtreecommitdiffstats
path: root/src/devices/base/device_group.h
blob: 1ecc6d18b9ef3bda8f741e55099289c04e11a053 (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 DEVICE_GROUP_H
#define DEVICE_GROUP_H

#if !defined(NO_KDE)
#  include <tqcolor.h>
#endif

#include "generic_device.h"
#include "common/common/group.h"
#include "common/common/streamer.h"
namespace Debugger { class DeviceSpecific; class Base; }

namespace Device
{
class Memory;

//----------------------------------------------------------------------------
class MemoryRange {
public:
  MemoryRange() {}
  virtual ~MemoryRange() {}
  virtual bool all() const { return true; }
};

//----------------------------------------------------------------------------
class GroupBase : public ::Group::Base
{
public:
  virtual Memory *createMemory(const Device::Data &data) const = 0;
  virtual TQString informationHtml(const Device::Data &data) const = 0;
#if !defined(NO_KDE)
  virtual TQPixmap memoryGraph(const Device::Data &data) const = 0;
#endif

protected:
  virtual void addDevice(const TQString &name, const Device::Data *data, ::Group::Support support) {
    const_cast<Device::Data *>(data)->_group = this;
    ::Group::Base::addDevice(name, data, support);
  }
};

template <class DataType>
class Group : public GroupBase, public DataStreamer<DataType>
{
protected:
  virtual void initSupported() {
    TQValueList<DataType *> list = fromCppString(dataStream(), dataSize());
    for (uint i=0; i<uint(list.count()); i++) addDevice(list[i]->name(), list[i], ::Group::Support::Tested);
  }
  virtual uint dataSize() const = 0;
  virtual const char *dataStream() const = 0;
};

//----------------------------------------------------------------------------
#if !defined(NO_KDE)
extern TQColor statusColor(Status status);
extern TQPixmap vddGraph(const TQString &xLabel, const TQString &yLabel, const TQValueVector<RangeBox> &boxes);
extern const Package *barPackage(const char *name, const Data &data);
extern TQPixmap pinsGraph(const Package &package);

extern TQString htmlInfo(const Data &data, const TQString &deviceHref, const TQString &documentHtml);
extern TQString htmlPinDiagrams(const Device::Data &data, const TQString &imagePrefix, TQMimeSourceFactory *msf);
extern TQString htmlVoltageFrequencyGraphs(const Device::Data &data, const TQString &imagePrefix, TQMimeSourceFactory *msf);

class MemoryGraphData
{
public:
  Address startAddress, endAddress;
  TQString start, end, label;
  int height;
  bool operator <(const MemoryGraphData &data) const { return ( startAddress < data.startAddress ); }
};
extern TQPixmap memoryGraph(const TQValueList<MemoryGraphData> &ranges);

#endif

} // namespace

#endif