Skip to content

Commit

Permalink
Make the configuration manager public
Browse files Browse the repository at this point in the history
  • Loading branch information
codemercenary committed Mar 1, 2016
1 parent ea8cf55 commit c694e73
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 25 deletions.
8 changes: 0 additions & 8 deletions src/autowiring/CoreContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -969,11 +969,3 @@ std::shared_ptr<CoreContext> CoreContext::SetCurrent(void) {
void CoreContext::EvictCurrent(void) {
autoCurrentContext.reset();
}

void CoreContext::ConfigSet(std::string name, std::string value) {
m_cfgManager.Set(std::move(name), std::move(value));
}

const std::string& CoreContext::ConfigGet(std::string name) const {
return m_cfgManager.Get(std::move(name));
}
18 changes: 4 additions & 14 deletions src/autowiring/CoreContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@ class CoreContext:
// Asserted any time a new object is added to the context
autowiring::signal<void(const CoreObjectDescriptor&)> newObject;

// The one and only configuration manager type
autowiring::ConfigManager Config;

virtual ~CoreContext(void);

/// <summary>
Expand Down Expand Up @@ -215,9 +218,6 @@ class CoreContext:
std::vector<ContextMember*> m_contextMembers;
std::vector<ExceptionFilter*> m_filters;

// The one and only configuration manager type
autowiring::ConfigManager m_cfgManager;

// Context members from other contexts that have snooped this context
std::set<AnySharedPointer> m_snoopers;

Expand Down Expand Up @@ -616,7 +616,7 @@ class CoreContext:
// value of pConfigDesc because it's a little faster and one necessarily follows the other
// We also want this to happen before the AutoInit call is made
if(autowiring::has_getconfigdescriptor<T>::value)
m_cfgManager.Register(static_cast<T*>(retVal.get()), *objDesc.pConfigDesc);
Config.Register(static_cast<T*>(retVal.get()), *objDesc.pConfigDesc);

// AutoInit if sensible to do so:
CallAutoInit(*retVal, has_autoinit<T>());
Expand Down Expand Up @@ -970,16 +970,6 @@ class CoreContext:
memo.onSatisfied += std::forward<Fn&&>(listener);
}

/// <summary>
/// Sets a single configuration value from the context
/// </summary>
void ConfigSet(std::string name, std::string value);

/// <summary>
/// Gets a configuration value from the context
/// </summary>
const std::string& ConfigGet(std::string name) const;

/// <summary>
/// Adds a teardown notifier which receives a pointer to this context on destruction
/// </summary>
Expand Down
6 changes: 3 additions & 3 deletions src/autowiring/test/AutoConfigTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ TEST_F(AutoConfigTest, Configurable) {

ASSERT_TRUE(c->cfg.clear_dirty()) << "Dirty flag was not set on a value that should have been dirty";
ASSERT_FALSE(c->cfg.is_dirty());
ctxt->ConfigSet("cfg", "888");
ctxt->Config.Set("cfg", "888");
ASSERT_TRUE(c->cfg.is_dirty()) << "Dirty flag not set correctly after being updated in configuration";
ASSERT_TRUE(c->cfg.clear_dirty());
ASSERT_EQ(888, c->cfg);
Expand All @@ -146,13 +146,13 @@ TEST_F(AutoConfigTest, ContextSetSimple) {
AutoCurrentContext ctxt;
AutoRequired<MyConfigurableClass> mcc;

ctxt->ConfigSet("b", "1029");
ctxt->Config.Set("b", "1029");
ASSERT_EQ(mcc->b, 1029);
}

TEST_F(AutoConfigTest, ContextSetAfter) {
AutoCurrentContext ctxt;
ctxt->ConfigSet("b", "10442");
ctxt->Config.Set("b", "10442");

AutoRequired<MyConfigurableClass> mcc;
ASSERT_EQ(mcc->b, 10442);
Expand Down

0 comments on commit c694e73

Please sign in to comment.