Repository: nifi-minifi-cpp
Updated Branches:
  refs/heads/master e24d54e03 -> 1cb750866


MINIFICPP-685 - Improve const correctness of property getters

This closes #449.

Signed-off-by: Marc Parisi <[email protected]>


Project: http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/repo
Commit: http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/commit/1cb75086
Tree: http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/tree/1cb75086
Diff: http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/diff/1cb75086

Branch: refs/heads/master
Commit: 1cb750866a972bd71e087f244e799de6a1827784
Parents: e24d54e
Author: Arpad Boda <[email protected]>
Authored: Mon Nov 26 11:30:20 2018 +0100
Committer: Marc Parisi <[email protected]>
Committed: Wed Nov 28 06:57:24 2018 -0500

----------------------------------------------------------------------
 libminifi/include/core/ConfigurableComponent.h | 12 ++++++------
 libminifi/include/core/ProcessContext.h        | 18 +++++++++---------
 libminifi/include/core/ProcessorNode.h         |  6 +++---
 libminifi/src/core/ConfigurableComponent.cpp   | 10 +++++-----
 4 files changed, 23 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/1cb75086/libminifi/include/core/ConfigurableComponent.h
----------------------------------------------------------------------
diff --git a/libminifi/include/core/ConfigurableComponent.h 
b/libminifi/include/core/ConfigurableComponent.h
index 9aff609..d7929a9 100644
--- a/libminifi/include/core/ConfigurableComponent.h
+++ b/libminifi/include/core/ConfigurableComponent.h
@@ -54,12 +54,12 @@ class ConfigurableComponent {
    * @param value value passed in by reference
    * @return result of getting property.
    */
-  bool getProperty(const std::string name, std::string &value);
+  bool getProperty(const std::string name, std::string &value) const;
 
   /**
    * Provides a reference for the property.
    */
-  bool getProperty(const std::string &name, Property &prop);
+  bool getProperty(const std::string &name, Property &prop) const;
   /**
    * Sets the property using the provided name
    * @param property name
@@ -116,7 +116,7 @@ class ConfigurableComponent {
    * @param value
    * @return
    */
-  bool getDynamicProperty(const std::string name, std::string &value);
+  bool getDynamicProperty(const std::string name, std::string &value) const;
 
   /**
    * Sets the value of a new dynamic property.
@@ -153,14 +153,14 @@ class ConfigurableComponent {
    *
    * @return vector of property keys
    */
-  std::vector<std::string> getDynamicPropertyKeys();
+  std::vector<std::string> getDynamicPropertyKeys() const;
 
   /**
    * Returns a vector all properties
    *
    * @return map of property keys to Property instances.
    */
-  std::map<std::string, Property> getProperties();
+  std::map<std::string, Property> getProperties() const;
 
   virtual ~ConfigurableComponent();
 
@@ -176,7 +176,7 @@ class ConfigurableComponent {
    */
   virtual bool canEdit()= 0;
 
-  std::mutex configuration_mutex_;
+  mutable std::mutex configuration_mutex_;
 
   // Supported properties
   std::map<std::string, Property> properties_;

http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/1cb75086/libminifi/include/core/ProcessContext.h
----------------------------------------------------------------------
diff --git a/libminifi/include/core/ProcessContext.h 
b/libminifi/include/core/ProcessContext.h
index 5d2ca55..352ef38 100644
--- a/libminifi/include/core/ProcessContext.h
+++ b/libminifi/include/core/ProcessContext.h
@@ -63,18 +63,18 @@ class ProcessContext : public 
controller::ControllerServiceLookup {
   virtual ~ProcessContext() {
   }
   // Get Processor associated with the Process Context
-  std::shared_ptr<ProcessorNode> getProcessorNode() {
+  std::shared_ptr<ProcessorNode> getProcessorNode() const {
     return processor_node_;
   }
-  bool getProperty(const std::string &name, std::string &value) {
+  bool getProperty(const std::string &name, std::string &value) const {
     return processor_node_->getProperty(name, value);
   }
   bool getProperty(const Property &property, std::string &value, const 
std::shared_ptr<FlowFile> &flow_file);
-  bool getDynamicProperty(const std::string &name, std::string &value) {
+  bool getDynamicProperty(const std::string &name, std::string &value) const {
     return processor_node_->getDynamicProperty(name, value);
   }
   bool getDynamicProperty(const Property &property, std::string &value, const 
std::shared_ptr<FlowFile> &flow_file);
-  std::vector<std::string> getDynamicPropertyKeys() {
+  std::vector<std::string> getDynamicPropertyKeys() const {
     return processor_node_->getDynamicPropertyKeys();
   }
   // Sets the property value using the property's string name
@@ -89,16 +89,16 @@ class ProcessContext : public 
controller::ControllerServiceLookup {
     return processor_node_->setProperty(prop, value);
   }
   // Whether the relationship is supported
-  bool isSupportedRelationship(Relationship relationship) {
+  bool isSupportedRelationship(Relationship relationship) const {
     return processor_node_->isSupportedRelationship(relationship);
   }
 
   // Check whether the relationship is auto terminated
-  bool isAutoTerminated(Relationship relationship) {
+  bool isAutoTerminated(Relationship relationship) const {
     return processor_node_->isAutoTerminated(relationship);
   }
   // Get ProcessContext Maximum Concurrent Tasks
-  uint8_t getMaxConcurrentTasks(void) {
+  uint8_t getMaxConcurrentTasks(void) const {
     return processor_node_->getMaxConcurrentTasks();
   }
   // Yield based on the yield period
@@ -114,11 +114,11 @@ class ProcessContext : public 
controller::ControllerServiceLookup {
    * Returns a reference to the content repository for the running instance.
    * @return content repository shared pointer.
    */
-  std::shared_ptr<core::ContentRepository> getContentRepository() {
+  std::shared_ptr<core::ContentRepository> getContentRepository() const {
     return content_repo_;
   }
 
-  std::shared_ptr<core::Repository> getFlowFileRepository() {
+  std::shared_ptr<core::Repository> getFlowFileRepository() const {
     return flow_repo_;
   }
 

http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/1cb75086/libminifi/include/core/ProcessorNode.h
----------------------------------------------------------------------
diff --git a/libminifi/include/core/ProcessorNode.h 
b/libminifi/include/core/ProcessorNode.h
index 22acea5..9c574b9 100644
--- a/libminifi/include/core/ProcessorNode.h
+++ b/libminifi/include/core/ProcessorNode.h
@@ -59,7 +59,7 @@ class ProcessorNode : public ConfigurableComponent, public 
Connectable {
    * @param value value passed in by reference
    * @return result of getting property.
    */
-  bool getProperty(const std::string &name, std::string &value) {
+  bool getProperty(const std::string &name, std::string &value) const {
     const std::shared_ptr<ConfigurableComponent> processor_cast = 
std::dynamic_pointer_cast<ConfigurableComponent>(processor_);
     if (nullptr != processor_cast)
       return processor_cast->getProperty(name, value);
@@ -89,7 +89,7 @@ class ProcessorNode : public ConfigurableComponent, public 
Connectable {
    * @param value value passed in by reference
    * @return result of getting property.
    */
-  bool getDynamicProperty(const std::string name, std::string &value) {
+  bool getDynamicProperty(const std::string name, std::string &value) const {
     const auto &processor_cast = 
std::dynamic_pointer_cast<ConfigurableComponent>(processor_);
     if (processor_cast) {
       return processor_cast->getDynamicProperty(name, value);
@@ -133,7 +133,7 @@ class ProcessorNode : public ConfigurableComponent, public 
Connectable {
    * @param value value passed in by reference
    * @return result of getting property.
    */
-  std::vector<std::string> getDynamicPropertyKeys() {
+  std::vector<std::string> getDynamicPropertyKeys() const {
     const auto &processor_cast = 
std::dynamic_pointer_cast<ConfigurableComponent>(processor_);
     if (processor_cast) {
       return processor_cast->getDynamicPropertyKeys();

http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/1cb75086/libminifi/src/core/ConfigurableComponent.cpp
----------------------------------------------------------------------
diff --git a/libminifi/src/core/ConfigurableComponent.cpp 
b/libminifi/src/core/ConfigurableComponent.cpp
index c413ab9..3923cfc 100644
--- a/libminifi/src/core/ConfigurableComponent.cpp
+++ b/libminifi/src/core/ConfigurableComponent.cpp
@@ -44,7 +44,7 @@ ConfigurableComponent::ConfigurableComponent(const 
ConfigurableComponent &&other
 ConfigurableComponent::~ConfigurableComponent() {
 }
 
-bool ConfigurableComponent::getProperty(const std::string &name, Property 
&prop) {
+bool ConfigurableComponent::getProperty(const std::string &name, Property 
&prop) const {
   std::lock_guard<std::mutex> lock(configuration_mutex_);
 
   auto &&it = properties_.find(name);
@@ -63,7 +63,7 @@ bool ConfigurableComponent::getProperty(const std::string 
&name, Property &prop)
  * @param value value passed in by reference
  * @return result of getting property.
  */
-bool ConfigurableComponent::getProperty(const std::string name, std::string 
&value) {
+bool ConfigurableComponent::getProperty(const std::string name, std::string 
&value) const {
   std::lock_guard<std::mutex> lock(configuration_mutex_);
 
   auto &&it = properties_.find(name);
@@ -168,7 +168,7 @@ bool 
ConfigurableComponent::setSupportedProperties(std::set<Property> properties
   return true;
 }
 
-bool ConfigurableComponent::getDynamicProperty(const std::string name, 
std::string &value) {
+bool ConfigurableComponent::getDynamicProperty(const std::string name, 
std::string &value) const {
   std::lock_guard<std::mutex> lock(configuration_mutex_);
 
   auto &&it = dynamic_properties_.find(name);
@@ -234,7 +234,7 @@ bool ConfigurableComponent::updateDynamicProperty(const 
std::string &name, const
   }
 }
 
-std::vector<std::string> ConfigurableComponent::getDynamicPropertyKeys() {
+std::vector<std::string> ConfigurableComponent::getDynamicPropertyKeys() const 
{
   std::lock_guard<std::mutex> lock(configuration_mutex_);
 
   std::vector<std::string> result;
@@ -246,7 +246,7 @@ std::vector<std::string> 
ConfigurableComponent::getDynamicPropertyKeys() {
   return result;
 }
 
-std::map<std::string, Property> ConfigurableComponent::getProperties() {
+std::map<std::string, Property> ConfigurableComponent::getProperties() const {
   std::lock_guard<std::mutex> lock(configuration_mutex_);
 
   std::map<std::string, Property> result;

Reply via email to