The Pedigree Project  0.1
DevicesCommand.h
1 /*
2  * Copyright (c) 2008-2014, Pedigree Developers
3  *
4  * Please see the CONTRIB file in the root of the source tree for a full
5  * list of contributors.
6  *
7  * Permission to use, copy, modify, and distribute this software for any
8  * purpose with or without fee is hereby granted, provided that the above
9  * copyright notice and this permission notice appear in all copies.
10  *
11  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18  */
19 
20 #ifndef DEVICESCOMMAND_H
21 #define DEVICESCOMMAND_H
22 
23 #include "pedigree/kernel/debugger/DebuggerCommand.h"
24 #include "pedigree/kernel/debugger/DebuggerIO.h"
25 #include "pedigree/kernel/debugger/Scrollable.h"
26 #include "pedigree/kernel/processor/state_forward.h"
27 #include "pedigree/kernel/processor/types.h"
28 #include "pedigree/kernel/utilities/StaticString.h"
29 #include "pedigree/kernel/utilities/Vector.h"
30 #include "pedigree/kernel/utilities/new"
31 
32 class Device;
33 
43 {
44  public:
49 
54 
58  void autocomplete(const HugeStaticString &input, HugeStaticString &output);
59 
63  bool execute(
64  const HugeStaticString &input, HugeStaticString &output,
65  InterruptState &state, DebuggerIO *screen);
66 
71  {
72  return NormalStaticString("devices");
73  }
74 
75  private:
76  class DeviceTree : public Scrollable
77  {
78  public:
79  DeviceTree();
80  ~DeviceTree()
81  {
82  }
83  const char *getLine1(
84  size_t index, DebuggerIO::Colour &colour,
85  DebuggerIO::Colour &bgColour);
86  const char *getLine2(
87  size_t index, size_t &colOffset, DebuggerIO::Colour &colour,
88  DebuggerIO::Colour &bgColour);
89  size_t getLineCount();
90  Device *getDevForIndex(size_t index);
91  size_t m_Line;
92 
93  private:
94  void probeDev(Device *pDev);
95  Vector<Device *> m_LinearTree;
96  };
97 
98  class DeviceInfo : public Scrollable
99  {
100  public:
101  DeviceInfo();
102  ~DeviceInfo()
103  {
104  }
105  void setDevice(Device *dev);
106  Device *getDevice()
107  {
108  return m_pDev;
109  }
110  const char *getLine1(
111  size_t index, DebuggerIO::Colour &colour,
112  DebuggerIO::Colour &bgColour);
113  const char *getLine2(
114  size_t index, size_t &colOffset, DebuggerIO::Colour &colour,
115  DebuggerIO::Colour &bgColour);
116  size_t getLineCount();
117 
118  private:
119  Device *m_pDev;
120  DeviceInfo(const DeviceInfo &);
121  void operator=(const DeviceInfo &);
122  };
123 
124  void drawBackground(size_t nLines, DebuggerIO *pScreen);
125 };
126 
129 #endif
void autocomplete(const HugeStaticString &input, HugeStaticString &output)
const NormalStaticString getString()
Definition: Device.h:43
bool execute(const HugeStaticString &input, HugeStaticString &output, InterruptState &state, DebuggerIO *screen)