Skip to content

Commit

Permalink
Refactored function parameters with in/out prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
swan-amazon committed Jun 6, 2024
1 parent 970a5c7 commit 3ccec30
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 67 deletions.
28 changes: 15 additions & 13 deletions src/app/server/DefaultEnhancedSetupFlowProvider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
#include <lib/core/CHIPConfig.h>
#include <platform/KeyValueStoreManager.h>

CHIP_ERROR chip::app::DefaultEnhancedSetupFlowProvider::Init(TermsAndConditionsProvider * aTermsAndConditionsProvider)
CHIP_ERROR chip::app::DefaultEnhancedSetupFlowProvider::Init(TermsAndConditionsProvider * const inTermsAndConditionsProvider)
{
mTermsAndConditionsProvider = aTermsAndConditionsProvider;
mTermsAndConditionsProvider = inTermsAndConditionsProvider;
return CHIP_NO_ERROR;
}

Expand Down Expand Up @@ -53,52 +53,54 @@ bool chip::app::DefaultEnhancedSetupFlowProvider::HasTermsAndConditionsRequiredA
return acceptedAcknowledgementsVersion >= requiredAcknowledgementsVersion;
}

CHIP_ERROR chip::app::DefaultEnhancedSetupFlowProvider::GetTermsAndConditionsRequiredAcknowledgements(uint16_t & value) const
CHIP_ERROR chip::app::DefaultEnhancedSetupFlowProvider::GetTermsAndConditionsRequiredAcknowledgements(uint16_t & outValue) const
{
uint16_t requiredAcknowledgements;
uint16_t requiredAcknowledgementsVersion;

mTermsAndConditionsProvider->GetRequirements(requiredAcknowledgements, requiredAcknowledgementsVersion);

value = requiredAcknowledgements;
outValue = requiredAcknowledgements;
return CHIP_NO_ERROR;
}

CHIP_ERROR chip::app::DefaultEnhancedSetupFlowProvider::GetTermsAndConditionsRequiredAcknowledgementsVersion(uint16_t & value) const
CHIP_ERROR
chip::app::DefaultEnhancedSetupFlowProvider::GetTermsAndConditionsRequiredAcknowledgementsVersion(uint16_t & outValue) const
{
uint16_t requiredAcknowledgements;
uint16_t requiredAcknowledgementsVersion;

mTermsAndConditionsProvider->GetRequirements(requiredAcknowledgements, requiredAcknowledgementsVersion);

value = requiredAcknowledgementsVersion;
outValue = requiredAcknowledgementsVersion;
return CHIP_NO_ERROR;
}

CHIP_ERROR chip::app::DefaultEnhancedSetupFlowProvider::GetTermsAndConditionsAcceptedAcknowledgements(uint16_t & value) const
CHIP_ERROR chip::app::DefaultEnhancedSetupFlowProvider::GetTermsAndConditionsAcceptedAcknowledgements(uint16_t & outValue) const
{
uint16_t acceptedAcknowledgements;
uint16_t acceptedAcknowledgementsVersion;

mTermsAndConditionsProvider->GetAcceptance(acceptedAcknowledgements, acceptedAcknowledgementsVersion);

value = acceptedAcknowledgements;
outValue = acceptedAcknowledgements;
return CHIP_NO_ERROR;
}

CHIP_ERROR chip::app::DefaultEnhancedSetupFlowProvider::GetTermsAndConditionsAcceptedAcknowledgementsVersion(uint16_t & value) const
CHIP_ERROR
chip::app::DefaultEnhancedSetupFlowProvider::GetTermsAndConditionsAcceptedAcknowledgementsVersion(uint16_t & outValue) const
{
uint16_t acceptedAcknowledgements;
uint16_t acceptedAcknowledgementsVersion;

mTermsAndConditionsProvider->GetAcceptance(acceptedAcknowledgements, acceptedAcknowledgementsVersion);

value = acceptedAcknowledgementsVersion;
outValue = acceptedAcknowledgementsVersion;
return CHIP_NO_ERROR;
}

CHIP_ERROR chip::app::DefaultEnhancedSetupFlowProvider::SetTermsAndConditionsAcceptance(uint16_t aTCAcknowledgements,
uint16_t aTCAcknowledgementsVersion)
CHIP_ERROR chip::app::DefaultEnhancedSetupFlowProvider::SetTermsAndConditionsAcceptance(uint16_t inTCAcknowledgementsValue,
uint16_t inTCAcknowledgementsVersionValue)
{
return mTermsAndConditionsProvider->SetAcceptance(aTCAcknowledgements, aTCAcknowledgementsVersion);
return mTermsAndConditionsProvider->SetAcceptance(inTCAcknowledgementsValue, inTCAcknowledgementsVersionValue);
}
19 changes: 10 additions & 9 deletions src/app/server/DefaultEnhancedSetupFlowProvider.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,10 @@ class DefaultEnhancedSetupFlowProvider : public EnhancedSetupFlowProvider
/**
* @brief Initializes the EnhancedSetupFlowProvider.
*
* @param[in] inTermsAndConditionsProvider The terms and conditions provide dependency.
* @return CHIP_ERROR On success returns CHIP_NO_ERROR, otherwise returns an error code.
*/
virtual CHIP_ERROR Init(TermsAndConditionsProvider * aTermsAndConditionsProvider);
virtual CHIP_ERROR Init(TermsAndConditionsProvider * const inTermsAndConditionsProvider);

/**
* @brief Checks if the required terms and conditions acknowledgements have been accepted.
Expand All @@ -55,34 +56,34 @@ class DefaultEnhancedSetupFlowProvider : public EnhancedSetupFlowProvider
/**
* @brief Retrieves the required terms and conditions acknowledgements.
*
* @param[out] value The value of the required acknowledgements.
* @param[out] outValue The value of the required acknowledgements.
* @return CHIP_ERROR On success returns CHIP_NO_ERROR, otherwise returns an error code.
*/
virtual CHIP_ERROR GetTermsAndConditionsRequiredAcknowledgements(uint16_t & value) const;
virtual CHIP_ERROR GetTermsAndConditionsRequiredAcknowledgements(uint16_t & outValue) const;

/**
* @brief Retrieves the required terms and conditions acknowledgements version.
*
* @param[out] value The value of the required acknowledgements version.
* @param[out] outValue The value of the required acknowledgements version.
* @return CHIP_ERROR On success returns CHIP_NO_ERROR, otherwise returns an error code.
*/
virtual CHIP_ERROR GetTermsAndConditionsRequiredAcknowledgementsVersion(uint16_t & value) const;
virtual CHIP_ERROR GetTermsAndConditionsRequiredAcknowledgementsVersion(uint16_t & outValue) const;

/**
* @brief Retrieves the accepted terms and conditions acknowledgements.
*
* @param[out] value The value of the accepted acknowledgements.
* @param[out] outValue The value of the accepted acknowledgements.
* @return CHIP_ERROR On success returns CHIP_NO_ERROR, otherwise returns an error code.
*/
virtual CHIP_ERROR GetTermsAndConditionsAcceptedAcknowledgements(uint16_t & value) const;
virtual CHIP_ERROR GetTermsAndConditionsAcceptedAcknowledgements(uint16_t & outValue) const;

/**
* @brief Retrieves the accepted terms and conditions acknowledgements version.
*
* @param[out] value The value of the accepted acknowledgements version.
* @param[out] outValue The value of the accepted acknowledgements version.
* @return CHIP_ERROR On success returns CHIP_NO_ERROR, otherwise returns an error code.
*/
virtual CHIP_ERROR GetTermsAndConditionsAcceptedAcknowledgementsVersion(uint16_t & value) const;
virtual CHIP_ERROR GetTermsAndConditionsAcceptedAcknowledgementsVersion(uint16_t & outValue) const;

/**
* @brief Sets the acceptance status of the terms and conditions.
Expand Down
31 changes: 16 additions & 15 deletions src/app/server/DefaultTermsAndConditionsProvider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,23 @@
#include <platform/KeyValueStoreManager.h>

CHIP_ERROR
chip::app::DefaultTermsAndConditionsProvider::Init(chip::DeviceLayer::PersistedStorage::KeyValueStoreManager * kvsManager)
chip::app::DefaultTermsAndConditionsProvider::Init(chip::DeviceLayer::PersistedStorage::KeyValueStoreManager * const inKvsManager)
{
mKeyValueStoreManager = kvsManager;
mKeyValueStoreManager = inKvsManager;
return CHIP_NO_ERROR;
}

CHIP_ERROR chip::app::DefaultTermsAndConditionsProvider::GetAcceptance(uint16_t & aAcknowledgements,
uint16_t & aAcknowledgementsVersion)
CHIP_ERROR chip::app::DefaultTermsAndConditionsProvider::GetAcceptance(uint16_t & outAcknowledgementsValue,
uint16_t & outAcknowledgementsVersionValue)
{
uint16_t acknowledgements = 0;
uint16_t acknowledgementsVersion = 0;

mKeyValueStoreManager->Get(kAcceptedAcknowledgementsKeyName, &acknowledgements, sizeof(acknowledgements));
mKeyValueStoreManager->Get(kAcceptedAcknowledgementsVersionKeyName, &acknowledgementsVersion, sizeof(acknowledgementsVersion));

aAcknowledgements = acknowledgements;
aAcknowledgementsVersion = acknowledgementsVersion;
outAcknowledgementsValue = acknowledgements;
outAcknowledgementsVersionValue = acknowledgementsVersion;

return CHIP_NO_ERROR;
}
Expand All @@ -51,19 +51,20 @@ CHIP_ERROR chip::app::DefaultTermsAndConditionsProvider::GetAcceptance(uint16_t
#error "CHIP_CONFIG_TC_REQUIRED_ACKNOWLEDGEMENTS_VERSION is not defined!"
#endif

CHIP_ERROR chip::app::DefaultTermsAndConditionsProvider::GetRequirements(uint16_t & aAcknowledgements,
uint16_t & aAcknowledgementsVersion)
CHIP_ERROR chip::app::DefaultTermsAndConditionsProvider::GetRequirements(uint16_t & outAcknowledgementsValue,
uint16_t & outAcknowledgementsVersionValue)
{
aAcknowledgements = CHIP_CONFIG_TC_REQUIRED_ACKNOWLEDGEMENTS;
aAcknowledgementsVersion = CHIP_CONFIG_TC_REQUIRED_ACKNOWLEDGEMENTS_VERSION;
outAcknowledgementsValue = CHIP_CONFIG_TC_REQUIRED_ACKNOWLEDGEMENTS;
outAcknowledgementsVersionValue = CHIP_CONFIG_TC_REQUIRED_ACKNOWLEDGEMENTS_VERSION;
return CHIP_NO_ERROR;
}

CHIP_ERROR chip::app::DefaultTermsAndConditionsProvider::SetAcceptance(uint16_t aAcceptedAcknowledgements,
uint16_t aAcceptedAcknowledgementsVersion)
CHIP_ERROR chip::app::DefaultTermsAndConditionsProvider::SetAcceptance(uint16_t inAcceptedAcknowledgementsValue,
uint16_t inAcceptedAcknowledgementsVersionValue)
{
mKeyValueStoreManager->Put(kAcceptedAcknowledgementsKeyName, &aAcceptedAcknowledgements, sizeof(aAcceptedAcknowledgements));
mKeyValueStoreManager->Put(kAcceptedAcknowledgementsVersionKeyName, &aAcceptedAcknowledgementsVersion,
sizeof(aAcceptedAcknowledgementsVersion));
mKeyValueStoreManager->Put(kAcceptedAcknowledgementsKeyName, &inAcceptedAcknowledgementsValue,
sizeof(inAcceptedAcknowledgementsValue));
mKeyValueStoreManager->Put(kAcceptedAcknowledgementsVersionKeyName, &inAcceptedAcknowledgementsVersionValue,
sizeof(inAcceptedAcknowledgementsVersionValue));
return CHIP_NO_ERROR;
}
21 changes: 11 additions & 10 deletions src/app/server/DefaultTermsAndConditionsProvider.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,36 +36,37 @@ class DefaultTermsAndConditionsProvider : public TermsAndConditionsProvider
/**
* @brief Initializes the TermsAndConditionsProvider.
*
* @param[in] inKvsManager The KVS manager dependency.
* @return CHIP_ERROR On success returns CHIP_NO_ERROR, otherwise returns an error code.
*/
virtual CHIP_ERROR Init(chip::DeviceLayer::PersistedStorage::KeyValueStoreManager * kvsManager);
virtual CHIP_ERROR Init(chip::DeviceLayer::PersistedStorage::KeyValueStoreManager * inKvsManager);

/**
* @brief Retrieves the acceptance status of the required terms and conditions.
*
* @param[out] aAcknowledgements The number of acknowledgements accepted.
* @param[out] aAcknowledgementsVersion The version of the accepted acknowledgements.
* @param[out] outAcknowledgementValues The number of acknowledgements accepted.
* @param[out] outAcknowledgementsVersionValue The version of the accepted acknowledgements.
* @return CHIP_ERROR On success returns CHIP_NO_ERROR, otherwise returns an error code.
*/
virtual CHIP_ERROR GetAcceptance(uint16_t & aAcknowledgements, uint16_t & aAcknowledgementsVersion);
virtual CHIP_ERROR GetAcceptance(uint16_t & outAcknowledgementsValue, uint16_t & outAcknowledgementsVersionValue);

/**
* @brief Retrieves the requirements of the terms and conditions.
*
* @param[out] aAcknowledgements The number of required acknowledgements.
* @param[out] aAcknowledgementsVersion The version of the required acknowledgements.
* @param[out] outAcknowledgementValues The number of required acknowledgements.
* @param[out] outAcknowledgementsVersionValue The version of the required acknowledgements.
* @return CHIP_ERROR On success returns CHIP_NO_ERROR, otherwise returns an error code.
*/
virtual CHIP_ERROR GetRequirements(uint16_t & aAcknowledgements, uint16_t & aAcknowledgementsVersion);
virtual CHIP_ERROR GetRequirements(uint16_t & outAcknowledgementsValue, uint16_t & outAcknowledgementsVersionValue);

/**
* @brief Sets the acceptance status of the required terms and conditions.
*
* @param[in] aAcknowledgements The number of acknowledgements to accept.
* @param[in] aAcknowledgementsVersion The version of the acknowledgements to accept.
* @param[in] inAcknowledgementValues The number of acknowledgements to accept.
* @param[in] inAcknowledgementsVersionValue The version of the acknowledgements to accept.
* @return CHIP_ERROR On success returns CHIP_NO_ERROR, otherwise returns an error code.
*/
virtual CHIP_ERROR SetAcceptance(uint16_t aAcknowledgements, uint16_t aAcknowledgementsVersion);
virtual CHIP_ERROR SetAcceptance(uint16_t inAcknowledgementsValue, uint16_t inAcknowledgementsVersionValue);

private:
chip::DeviceLayer::PersistedStorage::KeyValueStoreManager * mKeyValueStoreManager;
Expand Down
23 changes: 12 additions & 11 deletions src/app/server/EnhancedSetupFlowProvider.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,43 +55,44 @@ class EnhancedSetupFlowProvider
/**
* @brief Retrieves the required terms and conditions acknowledgements.
*
* @param[out] value The value of the required acknowledgements.
* @param[out] outValue The outValue of the required acknowledgements.
* @return CHIP_ERROR On success returns CHIP_NO_ERROR, otherwise returns an error code.
*/
virtual CHIP_ERROR GetTermsAndConditionsRequiredAcknowledgements(uint16_t & value) const = 0;
virtual CHIP_ERROR GetTermsAndConditionsRequiredAcknowledgements(uint16_t & outValue) const = 0;

/**
* @brief Retrieves the required terms and conditions acknowledgements version.
*
* @param[out] value The value of the required acknowledgements version.
* @param[out] outValue The outValue of the required acknowledgements version.
* @return CHIP_ERROR On success returns CHIP_NO_ERROR, otherwise returns an error code.
*/
virtual CHIP_ERROR GetTermsAndConditionsRequiredAcknowledgementsVersion(uint16_t & value) const = 0;
virtual CHIP_ERROR GetTermsAndConditionsRequiredAcknowledgementsVersion(uint16_t & outValue) const = 0;

/**
* @brief Retrieves the accepted terms and conditions acknowledgements.
*
* @param[out] value The value of the accepted acknowledgements.
* @param[out] outValue The outValue of the accepted acknowledgements.
* @return CHIP_ERROR On success returns CHIP_NO_ERROR, otherwise returns an error code.
*/
virtual CHIP_ERROR GetTermsAndConditionsAcceptedAcknowledgements(uint16_t & value) const = 0;
virtual CHIP_ERROR GetTermsAndConditionsAcceptedAcknowledgements(uint16_t & outValue) const = 0;

/**
* @brief Retrieves the accepted terms and conditions acknowledgements version.
*
* @param[out] value The value of the accepted acknowledgements version.
* @param[out] outValue The outValue of the accepted acknowledgements version.
* @return CHIP_ERROR On success returns CHIP_NO_ERROR, otherwise returns an error code.
*/
virtual CHIP_ERROR GetTermsAndConditionsAcceptedAcknowledgementsVersion(uint16_t & value) const = 0;
virtual CHIP_ERROR GetTermsAndConditionsAcceptedAcknowledgementsVersion(uint16_t & outValue) const = 0;

/**
* @brief Sets the acceptance status of the terms and conditions.
*
* @param[in] aTCAcknowledgements The acknowledgements to accept.
* @param[in] aTCAcknowledgementsVersion The version of the acknowledgements to accept.
* @param[in] inTCAcknowledgements The acknowledgements to accept.
* @param[in] inTCAcknowledgementsoutValue The version of the acknowledgements to accept.
* @return CHIP_ERROR On success returns CHIP_NO_ERROR, otherwise returns an error code.
*/
virtual CHIP_ERROR SetTermsAndConditionsAcceptance(uint16_t aTCAcknowledgements, uint16_t aTCAcknowledgementsVersion) = 0;
virtual CHIP_ERROR SetTermsAndConditionsAcceptance(uint16_t inTCAcknowledgementsValue,
uint16_t inTCAcknowledgementsoutValue) = 0;
};

}; // namespace app
Expand Down
18 changes: 9 additions & 9 deletions src/app/server/TermsAndConditionsProvider.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,29 +39,29 @@ class TermsAndConditionsProvider
/**
* @brief Retrieves the acceptance status of the required terms and conditions.
*
* @param[out] aAcknowledgements The number of acknowledgements accepted.
* @param[out] aAcknowledgementsVersion The version of the accepted acknowledgements.
* @param[out] outAcknowledgementsValue The number of acknowledgements accepted.
* @param[out] outAcknowledgementsVersionValue The version of the accepted acknowledgements.
* @return CHIP_ERROR On success returns CHIP_NO_ERROR, otherwise returns an error code.
*/
virtual CHIP_ERROR GetAcceptance(uint16_t & aAcknowledgements, uint16_t & aAcknowledgementsVersion) = 0;
virtual CHIP_ERROR GetAcceptance(uint16_t & outAcknowledgementsValue, uint16_t & outAcknowledgementsVersionValue) = 0;

/**
* @brief Retrieves the requirements of the terms and conditions.
*
* @param[out] aAcknowledgements The number of required acknowledgements.
* @param[out] aAcknowledgementsVersion The version of the required acknowledgements.
* @param[out] outAcknowledgementsValue The number of required acknowledgements.
* @param[out] outAcknowledgementsVersionValue The version of the required acknowledgements.
* @return CHIP_ERROR On success returns CHIP_NO_ERROR, otherwise returns an error code.
*/
virtual CHIP_ERROR GetRequirements(uint16_t & aAcknowledgements, uint16_t & aAcknowledgementsVersion) = 0;
virtual CHIP_ERROR GetRequirements(uint16_t & outAcknowledgementsValue, uint16_t & outAcknowledgementsVersionValue) = 0;

/**
* @brief Sets the acceptance status of the required terms and conditions.
*
* @param[in] aAcknowledgements The number of acknowledgements to accept.
* @param[in] aAcknowledgementsVersion The version of the acknowledgements to accept.
* @param[in] inAcknowledgementsValue The number of acknowledgements to accept.
* @param[in] inAcknowledgementsVersionValue The version of the acknowledgements to accept.
* @return CHIP_ERROR On success returns CHIP_NO_ERROR, otherwise returns an error code.
*/
virtual CHIP_ERROR SetAcceptance(uint16_t aAcknowledgements, uint16_t aAcknowledgementsVersion) = 0;
virtual CHIP_ERROR SetAcceptance(uint16_t inAcknowledgementsValue, uint16_t inAcknowledgementsVersionValue) = 0;
};

}; // namespace app
Expand Down

0 comments on commit 3ccec30

Please sign in to comment.