[Props] Change is_valid function signature
authorJihoon Lee <jhoon.it.lee@samsung.com>
Thu, 6 May 2021 04:36:22 +0000 (13:36 +0900)
committerJijoong Moon <jijoong.moon@samsung.com>
Tue, 11 May 2021 08:12:14 +0000 (17:12 +0900)
**Changes proposed in this PR:**
- s/is_valid/isValid
- change the function to const

**Self evaluation:**
1. Build test: [X]Passed [ ]Failed [ ]Skipped
2. Run test: [X]Passed [ ]Failed [ ]Skipped

Signed-off-by: Jihoon Lee <jhoon.it.lee@samsung.com>
nntrainer/layers/common_properties.h
nntrainer/utils/base_properties.h
test/unittest/unittest_properties.cpp

index 8658632..220a7cd 100644 (file)
@@ -43,7 +43,7 @@ public:
   static constexpr const char *key = "unit";    /**< unique key to access */
   using prop_tag = uint_prop_tag;               /**< property type */
 
-  bool is_valid(const unsigned int &v) override { return v > 0; }
+  bool isValid(const unsigned int &v) const override { return v > 0; }
 };
 
 } // namespace props
index d115925..6ec21ef 100644 (file)
@@ -125,7 +125,7 @@ public:
    * @throw std::invalid_argument if argument is not valid
    */
   void set(const T &v) {
-    NNTR_THROW_IF(is_valid(v) == false, std::invalid_argument)
+    NNTR_THROW_IF(isValid(v) == false, std::invalid_argument)
       << "argument is not valid";
     value = v;
   }
@@ -137,7 +137,7 @@ public:
    * @return true if valid
    * @return false if not valid
    */
-  virtual bool is_valid(const T &v) { return true; }
+  virtual bool isValid(const T &v) const { return true; }
 
 private:
   T value; /**< underlying data */
@@ -227,7 +227,7 @@ public:
    * @throw std::invalid_argument if argument is not valid
    */
   void set(const std::string &v) {
-    if (!is_valid(v)) {
+    if (!isValid(v)) {
       throw std::invalid_argument("argument is not valid");
     }
     value = v;
@@ -240,7 +240,7 @@ public:
    * @return true if valid
    * @return false if not valid
    */
-  virtual bool is_valid(const std::string &v) { return true; }
+  virtual bool isValid(const std::string &v) const { return true; }
 
 private:
   std::string value; /**< underlying data */
index c27f089..a320252 100644 (file)
@@ -37,7 +37,7 @@ public:
   static constexpr const char *key = "num_banana"; /**< unique key to access */
   using prop_tag = banana_prop_tag;                /**< property type */
 
-  bool is_valid(const int &v) override { return v >= 0; }
+  bool isValid(const int &v) const override { return v >= 0; }
 };
 
 /**
@@ -49,7 +49,7 @@ public:
   static constexpr const char *key = "quality_banana";
   using prop_tag = nntrainer::str_prop_tag;
 
-  bool is_valid(const std::string &v) override {
+  bool isValid(const std::string &v) const override {
     /// assuming quality of banana property must ends with word "good";
     return nntrainer::endswith(v, "good");
   }