Skip to content

Commit aed2ec9

Browse files
committed
Add unit category
1 parent 0195043 commit aed2ec9

File tree

3 files changed

+27
-2
lines changed

3 files changed

+27
-2
lines changed

src/M5UnitComponent.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -366,8 +366,8 @@ std::string Component::debugInfo() const
366366
tmp = m5::utility::formatString("%p:%u Type:%d", _adapter.get(), _adapter.use_count(), _adapter->type());
367367
break;
368368
}
369-
return m5::utility::formatString("[%s]:ID{0X%08x}:%s parent:%u children:%zu/%u", deviceName(), identifier(),
370-
tmp.c_str(), hasParent(), childrenSize(), _component_cfg.max_children);
369+
return m5::utility::formatString("[%s]:ID{0X%08x}:%s CH:%d parent:%u children:%zu/%u", deviceName(), identifier(),
370+
tmp.c_str(), channel(), hasParent(), childrenSize(), _component_cfg.max_children);
371371
}
372372

373373
// Explicit template instantiation

src/M5UnitComponent.hpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,11 @@ class Component {
127127
{
128128
return unit_attribute();
129129
}
130+
//! @brief Gets the category
131+
inline types::category_t category() const
132+
{
133+
return unit_category();
134+
}
130135
//! @brief Gets the registered order (== 0 means not yet)
131136
inline uint32_t order() const
132137
{
@@ -247,6 +252,13 @@ class Component {
247252
{
248253
return _parent;
249254
}
255+
#if 0
256+
//! @brief Gets the parent unit
257+
inline const Component* parent() const
258+
{
259+
return _parent;
260+
}
261+
#endif
250262
//! @brief Gets the device connected to the specified channel
251263
Component* child(const uint8_t chhanle) const;
252264
//! @brief Connect the unit to the specified channel
@@ -498,6 +510,10 @@ class Component {
498510
virtual const char* unit_device_name() const = 0;
499511
virtual types::uid_t unit_identifier() const = 0;
500512
virtual types::attr_t unit_attribute() const = 0;
513+
inline virtual types::category_t unit_category() const
514+
{
515+
return types::category_t::None;
516+
}
501517
inline virtual bool in_periodic() const
502518
{
503519
return _periodic;

src/m5_unit_component/types.hpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,15 @@ namespace unit {
2828
*/
2929
namespace types {
3030

31+
/*!
32+
@enum category_t
33+
@brief Unit category (used for static class determination)
34+
*/
35+
enum class category_t {
36+
None,
37+
UnitLED, //!< Derived from UnitLED
38+
};
39+
3140
using uid_t = uint32_t; //!< @brief Component unique identifier
3241
using attr_t = uint32_t; //!< @brief Component attribute bits
3342
using elapsed_time_t = unsigned long; //!< @brief Elapsed time unit (ms)

0 commit comments

Comments
 (0)