Skip to content

Commit

Permalink
fix some stuff for codacy
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredmales committed Dec 20, 2023
1 parent 7d7c5f7 commit 0306652
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 211 deletions.
127 changes: 5 additions & 122 deletions INDI/libcommon/IndiElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,161 +21,44 @@ using pcf::IndiElement;

IndiElement::IndiElement()
{
m_szMax = "0";
m_szMin = "0";
m_szSize = "0";
m_szStep = "0";
m_lsValue = UnknownLightState;
m_ssValue = UnknownSwitchState;
m_szFormat = "%g";
}

////////////////////////////////////////////////////////////////////////////////
/// Constructor with a name - this will be used often.

IndiElement::IndiElement( const string &szName )
{
m_szMax = "0";
m_szMin = "0";
m_szName = szName;
m_szSize = "0";
m_szStep = "0";
m_lsValue = UnknownLightState;
m_ssValue = UnknownSwitchState;
m_szFormat = "%g";
}
/*
////////////////////////////////////////////////////////////////////////////////
/// Constructor with a name and a bool value.
IndiElement::IndiElement( const string &szName,
const bool &oValue )
{
m_szMax = "0";
m_szMin = "0";
m_szName = szName;
m_szSize = "0";
m_szStep = "0";
m_lsValue = UnknownLightState;
m_ssValue = UnknownSwitchState;
m_szFormat = "%g";
stringstream ssValue;
ssValue << boolalpha << oValue;
m_szValue = ssValue.str();
}
////////////////////////////////////////////////////////////////////////////////
/// Constructor with a name and a double value.
IndiElement::IndiElement( const string &szName,
const double &xValue )
{
m_szMax = "0";
m_szMin = "0";
m_szName = szName;
m_szSize = "0";
m_szStep = "0";
m_lsValue = UnknownLightState;
m_ssValue = UnknownSwitchState;
m_szFormat = "%g";
stringstream ssValue;
ssValue << xValue;
m_szValue = ssValue.str();
}
////////////////////////////////////////////////////////////////////////////////
/// Constructor with a name and a float value.
IndiElement::IndiElement( const string &szName,
const float &eValue )
IndiElement::IndiElement( const string &szName ) : m_szName(szName)
{
m_szMax = "0";
m_szMin = "0";
m_szName = szName;
m_szSize = "0";
m_szStep = "0";
m_lsValue = UnknownLightState;
m_ssValue = UnknownSwitchState;
m_szFormat = "%g";
stringstream ssValue;
ssValue << eValue;
m_szValue = ssValue.str();
}

////////////////////////////////////////////////////////////////////////////////
/// Constructor with a name and an int value.
IndiElement::IndiElement( const string &szName,
const int &iValue )
{
m_szMax = "0";
m_szMin = "0";
m_szName = szName;
m_szSize = "0";
m_szStep = "0";
m_lsValue = UnknownLightState;
m_ssValue = UnknownSwitchState;
m_szFormat = "%g";
stringstream ssValue;
ssValue << iValue;
m_szValue = ssValue.str();
}
*/
////////////////////////////////////////////////////////////////////////////////
/// Constructor with a name and a string value.

IndiElement::IndiElement( const string &szName,
const string &szValue )
const string &szValue ) : m_szName(szName), m_szValue(szValue)
{
m_szMax = "0";
m_szMin = "0";
m_szName = szName;
m_szSize = "0";
m_szStep = "0";
m_lsValue = UnknownLightState;
m_ssValue = UnknownSwitchState;
m_szFormat = "%g";

m_szValue = szValue;
}

////////////////////////////////////////////////////////////////////////////////
/// Constructor with a name and a char pointer value.

IndiElement::IndiElement( const string &szName,
const char *pcValue )
const char *pcValue ) : m_szName(szName), m_szValue(pcValue)
{
m_szMax = "0";
m_szMin = "0";
m_szName = szName;
m_szSize = "0";
m_szStep = "0";
m_lsValue = UnknownLightState;
m_ssValue = UnknownSwitchState;
m_szFormat = "%g";

m_szValue = string( pcValue );
}

////////////////////////////////////////////////////////////////////////////////
/// Constructor with a name and a LightStateType value.

IndiElement::IndiElement( const string &szName,
const LightStateType &tValue ) : m_szFormat("%g"), m_szMax("0"), m_szMin("0"), m_szName(szName), m_szSize("0"),
m_szStep("0"), m_lsValue(tValue), m_ssValue(UnknownSwitchState)
const LightStateType &tValue ) : m_szName(szName), m_lsValue(tValue)
{
}

////////////////////////////////////////////////////////////////////////////////
/// Constructor with a name and a SwitchStateType value.

IndiElement::IndiElement( const string &szName,
const SwitchStateType &tValue ) : m_szFormat("%g"), m_szMax("0"), m_szMin("0"), m_szName(szName), m_szSize("0"),
m_szStep("0"), m_lsValue(UnknownLightState), m_ssValue(tValue)
const SwitchStateType &tValue ) : m_szName(szName), m_ssValue(tValue)
{
}

Expand Down
36 changes: 26 additions & 10 deletions INDI/libcommon/IndiElement.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,19 @@ class IndiElement

// All the different data this can store.
const std::string &getFormat() const;

const std::string &getLabel() const;

const std::string &getMax() const;

const std::string &getMin() const;

const std::string &getName() const;

const std::string &getSize() const;
template <class TT> TT getSize() const;

template <class TT> typename std::remove_reference<TT>::type getSize() const;

const std::string &getStep() const;

/// Different ways of getting the data in this element.
Expand Down Expand Up @@ -201,25 +208,35 @@ class IndiElement
// Members.
private:
/// If this is a number or BLOB, this is the 'printf' format.
std::string m_szFormat;
std::string m_szFormat {"%g"};

/// A label, usually used in a GUI.
std::string m_szLabel;

/// If this is a number, this is its maximum value.
std::string m_szMax;
std::string m_szMax {"0"};

/// If this is a number, this is its minimum value.
std::string m_szMin;
std::string m_szMin {"0"};

/// The name of this element.
std::string m_szName;

/// If this is a BLOB, this is the number of bytes for it.
std::string m_szSize;
std::string m_szSize {"0"};

/// If this is a number, this is increment for it.
std::string m_szStep;
std::string m_szStep {"0"};

/// This is the value of the data.
std::string m_szValue;

/// This can also be the value.
LightStateType m_lsValue;
LightStateType m_lsValue {UnknownLightState};

/// This can also be the value.
SwitchStateType m_ssValue;
SwitchStateType m_ssValue {UnknownSwitchState};

// A read write lock to protect the internal data.
mutable pcf::ReadWriteLock m_rwData;

Expand Down Expand Up @@ -382,8 +399,7 @@ template <class TT> void pcf::IndiElement::setSize( const TT &ttSize )

////////////////////////////////////////////////////////////////////////////////
/// Get the size as an arbitrary type.

template <class TT> TT pcf::IndiElement::getSize() const
template <class TT> typename std::remove_reference<TT>::type pcf::IndiElement::getSize() const
{
pcf::ReadWriteLock::AutoRLock rwAuto( &m_rwData );

Expand Down
70 changes: 17 additions & 53 deletions INDI/libcommon/IndiProperty.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,45 +23,28 @@ using pcf::IndiProperty;

IndiProperty::IndiProperty()
{
m_tType = Unknown;
m_tPerm = UnknownPropertyPerm;
m_oRequested = false;
m_tRule = UnknownSwitchRule;
m_tState = UnknownPropertyState;
m_xTimeout = 0.0f;
m_beValue = UnknownBLOBEnable;
//m_tPerm = UnknownPropertyPerm;
//m_oRequested = false;
//m_tRule = UnknownSwitchRule;
//m_tState = UnknownPropertyState;
//m_xTimeout = 0.0f;
//m_beValue = UnknownBLOBEnable;
}

////////////////////////////////////////////////////////////////////////////////
/// Constructor with type - this will be used often.

IndiProperty::IndiProperty( const Type &tType )
IndiProperty::IndiProperty( const Type &tType ) : m_tType(tType)
{
m_tType = tType;
m_tPerm = UnknownPropertyPerm;
m_oRequested = false;
m_tRule = UnknownSwitchRule;
m_tState = UnknownPropertyState;
m_xTimeout = 0.0f;
m_beValue = UnknownBLOBEnable;
}

////////////////////////////////////////////////////////////////////////////////
/// Constructor with type, device and name - this will be used often.

IndiProperty::IndiProperty( const Type &tType,
const string &szDevice,
const string &szName )
const string &szName ) : m_szDevice(szDevice), m_szName(szName), m_tType(tType)
{
m_tType = tType;
m_szDevice = szDevice;
m_szName = szName;
m_tPerm = UnknownPropertyPerm;
m_oRequested = false;
m_tRule = UnknownSwitchRule;
m_tState = UnknownPropertyState;
m_xTimeout = 0.0f;
m_beValue = UnknownBLOBEnable;
}

////////////////////////////////////////////////////////////////////////////////
Expand All @@ -72,40 +55,21 @@ IndiProperty::IndiProperty( const Type &tType,
const string &szName,
const PropertyStateType &tState,
const PropertyPermType &tPerm,
const SwitchRuleType &tRule )
const SwitchRuleType &tRule ) : m_szDevice(szDevice), m_szName(szName), m_tPerm(tPerm),
m_tRule(tRule), m_tState(tState), m_tType(tType)
{
m_tType = tType;
m_szDevice = szDevice;
m_szName = szName;
m_tPerm = tPerm;
m_oRequested = false;
m_tRule = tRule;
m_tState = tState;
m_xTimeout = 0.0f;
m_beValue = UnknownBLOBEnable;
}

////////////////////////////////////////////////////////////////////////////////
/// Copy constructor.

IndiProperty::IndiProperty(const IndiProperty &ipRhs )
{
m_szDevice = ipRhs.m_szDevice;
m_szGroup = ipRhs.m_szGroup;
m_szLabel = ipRhs.m_szLabel;
m_szMessage = ipRhs.m_szMessage;
m_szName = ipRhs.m_szName;
m_tPerm = ipRhs.m_tPerm;
m_oRequested = ipRhs.m_oRequested;
m_tRule = ipRhs.m_tRule;
m_tState = ipRhs.m_tState;
m_xTimeout = ipRhs.m_xTimeout;
m_tsTimeStamp = ipRhs.m_tsTimeStamp;
m_szVersion = ipRhs.m_szVersion;
m_beValue = ipRhs.m_beValue;

m_mapElements = ipRhs.m_mapElements;
m_tType = ipRhs.m_tType;
IndiProperty::IndiProperty(const IndiProperty &ipRhs ) : m_szDevice(ipRhs.m_szDevice), m_szGroup(ipRhs.m_szGroup), m_szLabel(ipRhs.m_szLabel),
m_szMessage(ipRhs.m_szMessage), m_szName(ipRhs.m_szName), m_tPerm(ipRhs.m_tPerm),
m_tRule(ipRhs.m_tRule), m_tState(ipRhs.m_tState), m_xTimeout(ipRhs.m_xTimeout),
m_oRequested(ipRhs.m_oRequested), m_tsTimeStamp(ipRhs.m_tsTimeStamp),
m_szVersion(ipRhs.m_szVersion), m_beValue(ipRhs.m_beValue),
m_mapElements(ipRhs.m_mapElements), m_tType(ipRhs.m_tType)
{
}

////////////////////////////////////////////////////////////////////////////////
Expand Down
Loading

0 comments on commit 0306652

Please sign in to comment.