Skip to content

Commit 882e1b2

Browse files
committed
namespace dicontainercpp added
1 parent 94b6182 commit 882e1b2

13 files changed

+38
-2
lines changed

run coverage.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
c:\Utils\CoverageCpp\Coverage-x64.exe -o C:\Users\v.bloshchanevich\Source\Repos\DIContainerCpp\CodeCoverageTest.cov -p C:\Users\v.bloshchanevich\Source\Repos\DIContainerCpp\src -- C:\Users\v.bloshchanevich\Source\Repos\DIContainerCpp\tests\Debug\runUnitTests.exe

src/ComPtr.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#pragma once
22
#include "IUnknown.h"
33

4+
namespace dicontainercpp {
5+
46
template<class _T, UID _id>
57
class ComPtr
68
{
@@ -79,3 +81,5 @@ class ComPtr
7981
private:
8082
_T* ptr;
8183
};
84+
85+
}

src/DIContainer.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#include "DIContainer.h"
22
#include <sstream>
33

4+
namespace dicontainercpp {
5+
46
// Utility functions
57
template<class _Val>
68
void CheckIfAlreadyRegistered(std::unordered_map<UID, _Val>& map, UID id)
@@ -107,3 +109,5 @@ IUnknown* DIContainer::Resolve(UID id, CreateInstanceFunc createFunction)
107109

108110
return component->QueryInterface(id);
109111
}
112+
113+
}

src/DIContainer.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
#include "IComponent.h"
77
#include "IContainer.h"
88

9+
namespace dicontainercpp {
10+
911
enum class CreationPolicy
1012
{
1113
NewInstance,
@@ -53,3 +55,5 @@ class DIContainer : public IContainer
5355
};
5456

5557
std::ostream& operator << (std::ostream& os, DIContainer& cont);
58+
59+
}

src/IComponent.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
#include <vector>
33
#include "IUnknown.h"
44

5+
namespace dicontainercpp {
6+
57
const UID UIDIComponent = 1;
68

79
struct IComponent : IUnknown
@@ -12,3 +14,5 @@ struct IComponent : IUnknown
1214
// `id` will have been returned by `GetDependencies()`
1315
virtual void SetDependency(UID id, IUnknown* dependency) = 0;
1416
};
17+
18+
}

src/IContainer.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
#pragma once
22
#include "IUnknown.h"
33

4+
namespace dicontainercpp {
5+
46
struct IContainer
57
{
68
// Return the registered in the DIContainer interface by `id`
79
virtual IUnknown* GetInterface(UID id) = 0;
8-
};
10+
};
11+
12+
}

src/IUnknown.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#pragma once
22

3+
namespace dicontainercpp {
34

45
using UID = long;
56

@@ -11,4 +12,6 @@ struct IUnknown
1112
virtual unsigned int AddRef() = 0; // Increase the interface's RefCount
1213
virtual unsigned int Release() = 0; // Decrease the interface's RefCount. If zero, the component must be free itself.
1314
virtual IUnknown* QueryInterface(UID id) = 0; // Return the implementation of the interface known by `id`.
14-
};
15+
};
16+
17+
}

tests/CyclicInterface.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#pragma once
22

3+
using namespace dicontainercpp;
4+
35
const UID UIDComponent3 = 103;
46

57
struct IComponent3 : IUnknown

tests/TestComp.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#pragma once
22
#include "../src/IComponent.h"
33

4+
using namespace dicontainercpp;
5+
46
const UID UIDTestComp = 201;
57
struct ITestComp : public IUnknown
68
{

tests/component1.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#pragma once
22
#include "../src/IComponent.h"
33

4+
using namespace dicontainercpp;
5+
46
const UID UIDComponent1 = 101;
57
struct IComponent1 : public IUnknown
68
{

0 commit comments

Comments
 (0)