-
Notifications
You must be signed in to change notification settings - Fork 250
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BugFix when creating instance name for factory components (#720)
The auto generation code uses the component name from the manifest.json file when creating the name of the constructor and destructor for the service instance. The factory component was using the name of the implementation class. This coding change fixes this bug so the name of the component is always used. The name of the component is an optional parameter in the manifest.json file. It defaults to the implementation class when not provided. The implementation class will be used for the instance name in those cases. Signed off by The MathWorks, Inc. <pelliott@mathworks.com>
- Loading branch information
1 parent
f0a6c6f
commit a543239
Showing
12 changed files
with
129 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
usFunctionCreateDSTestBundle(TestBundleDSCA21) | ||
|
||
usFunctionCreateTestBundleWithResources(TestBundleDSCA21 | ||
SOURCES src/ServiceImpl.cpp ${_glue_file} | ||
RESOURCES manifest.json | ||
BUNDLE_SYMBOLIC_NAME TestBundleDSCA21 | ||
OTHER_LIBRARIES usTestInterfaces usServiceComponent) | ||
|
21 changes: 21 additions & 0 deletions
21
compendium/test_bundles/TestBundleDSCA21/resources/manifest.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"bundle.symbolic_name" : "TestBundleDSCA21", | ||
"scr" : { | ||
"version" : 1, | ||
"components" : [{ | ||
"name": "ServiceComponentName", | ||
"enabled" : true, | ||
"immediate": false, | ||
"implementation-class": "sample::ServiceComponentCA21", | ||
"configuration-policy" : "require", | ||
"configuration-pid" : ["ServiceComponentPid"], | ||
"factory" : "factory id", | ||
"factory-properties" : { | ||
"abc" : "123" | ||
}, | ||
"service": { | ||
"interfaces": ["test::CAInterface"] | ||
} | ||
}] | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
compendium/test_bundles/TestBundleDSCA21/src/ServiceComponents.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#ifndef SERVICECOMPONENTS_HPP | ||
#define SERVICECOMPONENTS_HPP | ||
|
||
#include "ServiceImpl.hpp" | ||
|
||
#endif |
19 changes: 19 additions & 0 deletions
19
compendium/test_bundles/TestBundleDSCA21/src/ServiceImpl.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#include "ServiceImpl.hpp" | ||
#include <iostream> | ||
|
||
namespace sample { | ||
|
||
void ServiceComponentCA21::Modified( | ||
const std::shared_ptr<ComponentContext>& /*context*/, | ||
const std::shared_ptr<cppmicroservices::AnyMap>& configuration) | ||
{ | ||
std::lock_guard<std::mutex> lock(propertiesLock); | ||
properties = configuration; | ||
} | ||
cppmicroservices::AnyMap ServiceComponentCA21::GetProperties() | ||
{ | ||
std::lock_guard<std::mutex> lock(propertiesLock); | ||
return *properties; | ||
} | ||
|
||
} |
29 changes: 29 additions & 0 deletions
29
compendium/test_bundles/TestBundleDSCA21/src/ServiceImpl.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#ifndef _SERVICE_IMPL_HPP_ | ||
#define _SERVICE_IMPL_HPP_ | ||
|
||
#include "TestInterfaces/Interfaces.hpp" | ||
#include "cppmicroservices/servicecomponent/ComponentContext.hpp" | ||
#include <mutex> | ||
|
||
using ComponentContext = cppmicroservices::service::component::ComponentContext; | ||
|
||
namespace sample { | ||
class ServiceComponentCA21 : public test::CAInterface | ||
{ | ||
public: | ||
ServiceComponentCA21(const std::shared_ptr<cppmicroservices::AnyMap>& props) | ||
: properties(props) | ||
{} | ||
void Modified(const std::shared_ptr<ComponentContext>& context, | ||
const std::shared_ptr<cppmicroservices::AnyMap>& configuration); | ||
cppmicroservices::AnyMap GetProperties(); | ||
|
||
~ServiceComponentCA21() = default; | ||
|
||
private: | ||
std::mutex propertiesLock; | ||
std::shared_ptr<cppmicroservices::AnyMap> properties; | ||
}; | ||
} | ||
|
||
#endif // _SERVICE_IMPL_HPP_ |