Devices: Make get methods of Device const
adds const qualifiers to the devices class getter methods. Resolves the TODO: Make Get methods of device const in documentation/Todo.txt Changes: - Added const qualifiers to getter methods in Device.h and Device.cpp - replaced operator[] with find() in Device.h and Device.cpp to prevent map modification in const - Removed the corresponding Todo entry in documentation/Todo.txt Change-Id: I78d5ea31b2d7539bcefda7b3e57a484d16103c25 Reviewed-on: https://review.haiku-os.org/c/haiku/+/10666 Tested-by: Commit checker robot <[email protected]> Reviewed-by: Adrien Destugues <[email protected]>
This commit is contained in:
committed by
Adrien Destugues
parent
734225977f
commit
84dc21e19e
+22
-10
@@ -74,30 +74,42 @@ Device::~Device()
|
|||||||
|
|
||||||
|
|
||||||
BString
|
BString
|
||||||
Device::GetName()
|
Device::GetName() const
|
||||||
{
|
{
|
||||||
return fAttributeMap[B_TRANSLATE("Device name")];
|
AttributeMapIterator it = fAttributeMap.find(B_TRANSLATE("Device name"));
|
||||||
|
if (it != fAttributeMap.end())
|
||||||
|
return it->second;
|
||||||
|
return BString("unkown");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BString
|
BString
|
||||||
Device::GetManufacturer()
|
Device::GetManufacturer() const
|
||||||
{
|
{
|
||||||
return fAttributeMap[B_TRANSLATE("Manufacturer")];
|
AttributeMapIterator it = fAttributeMap.find(B_TRANSLATE("Manufacturer"));
|
||||||
|
if (it != fAttributeMap.end())
|
||||||
|
return it->second;
|
||||||
|
return BString("Unknown");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BString
|
BString
|
||||||
Device::GetDriverUsed()
|
Device::GetDriverUsed() const
|
||||||
{
|
{
|
||||||
return fAttributeMap[B_TRANSLATE("Driver used")];
|
AttributeMapIterator it = fAttributeMap.find(B_TRANSLATE("Driver used"));
|
||||||
|
if (it != fAttributeMap.end())
|
||||||
|
return it->second;
|
||||||
|
return BString("Unknown");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BString
|
BString
|
||||||
Device::GetDevPathsPublished()
|
Device::GetDevPathsPublished() const
|
||||||
{
|
{
|
||||||
return fAttributeMap[B_TRANSLATE("Device paths")];
|
AttributeMapIterator it = fAttributeMap.find(B_TRANSLATE("Device paths"));
|
||||||
|
if (it != fAttributeMap.end())
|
||||||
|
return it->second;
|
||||||
|
return BString("Unknown");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -112,7 +124,7 @@ Device::SetAttribute(const BString& name, const BString& value)
|
|||||||
|
|
||||||
|
|
||||||
Attributes
|
Attributes
|
||||||
Device::GetAllAttributes()
|
Device::GetAllAttributes() const
|
||||||
{
|
{
|
||||||
Attributes attributes;
|
Attributes attributes;
|
||||||
AttributeMapIterator iter;
|
AttributeMapIterator iter;
|
||||||
@@ -124,7 +136,7 @@ Device::GetAllAttributes()
|
|||||||
|
|
||||||
|
|
||||||
BString
|
BString
|
||||||
Device::GetAllStrings()
|
Device::GetAllStrings() const
|
||||||
{
|
{
|
||||||
BString str;
|
BString str;
|
||||||
AttributeMapIterator iter;
|
AttributeMapIterator iter;
|
||||||
|
|||||||
@@ -83,10 +83,10 @@ public:
|
|||||||
const BString& devPathsPublished = "unknown");
|
const BString& devPathsPublished = "unknown");
|
||||||
virtual ~Device();
|
virtual ~Device();
|
||||||
|
|
||||||
virtual BString GetName();
|
virtual BString GetName() const;
|
||||||
virtual BString GetManufacturer();
|
virtual BString GetManufacturer() const;
|
||||||
virtual BString GetDriverUsed();
|
virtual BString GetDriverUsed() const;
|
||||||
virtual BString GetDevPathsPublished();
|
virtual BString GetDevPathsPublished() const;
|
||||||
virtual Category GetCategory() const
|
virtual Category GetCategory() const
|
||||||
{ return fCategory; }
|
{ return fCategory; }
|
||||||
virtual Device* GetPhysicalParent() const
|
virtual Device* GetPhysicalParent() const
|
||||||
@@ -94,12 +94,16 @@ public:
|
|||||||
virtual BusType GetBusType() const
|
virtual BusType GetBusType() const
|
||||||
{ return fBusType; }
|
{ return fBusType; }
|
||||||
|
|
||||||
virtual Attributes GetAllAttributes();
|
virtual Attributes GetAllAttributes() const;
|
||||||
virtual BString GetAllStrings();
|
virtual BString GetAllStrings() const;
|
||||||
|
|
||||||
virtual Attribute GetAttribute(const BString& name)
|
virtual Attribute GetAttribute(const BString& name) const
|
||||||
{ return Attribute(name.String(),
|
{
|
||||||
fAttributeMap[name]); }
|
AttributeMapIterator it = fAttributeMap.find(name);
|
||||||
|
if (it != fAttributeMap.end())
|
||||||
|
return Attribute(name.String(), it->second);
|
||||||
|
return Attribute(name.String(), "");
|
||||||
|
}
|
||||||
|
|
||||||
virtual void SetAttribute(const BString& name,
|
virtual void SetAttribute(const BString& name,
|
||||||
const BString& value);
|
const BString& value);
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
TODO:
|
TODO:
|
||||||
* There still is a memory leak somewhere, hunt it down
|
* There still is a memory leak somewhere, hunt it down
|
||||||
* Make Get methods of Device const
|
|
||||||
* Fix view color?
|
* Fix view color?
|
||||||
* Fix forwarding of messages to view
|
* Fix forwarding of messages to view
|
||||||
* Bottom scrollbar strangeness
|
* Bottom scrollbar strangeness
|
||||||
|
|||||||
Reference in New Issue
Block a user