Merge lp:~michihenning/unity-scopes-api/valgrind-suppressions into lp:unity-scopes-api
- valgrind-suppressions
- Merge into trunk
Proposed by
Michi Henning
Status: | Merged |
---|---|
Approved by: | Michi Henning |
Approved revision: | 20 |
Merged at revision: | 19 |
Proposed branch: | lp:~michihenning/unity-scopes-api/valgrind-suppressions |
Merge into: | lp:unity-scopes-api |
Diff against target: |
11176 lines (+8796/-524) 177 files modified
CMakeLists.txt (+115/-24) demo/CMakeLists.txt (+18/-0) demo/Ice.Config.in (+9/-0) demo/client.cpp (+106/-0) demo/scope-A.cpp (+69/-0) demo/scope-B.cpp (+128/-0) demo/scope-C.cpp (+104/-0) demo/scope-D.cpp (+103/-0) demo/scoperunner-A.cpp (+57/-0) demo/scoperunner-BC.cpp (+65/-0) demo/scoperunner-D.cpp (+57/-0) include/unity/CMakeLists.txt (+1/-2) include/unity/api/CMakeLists.txt (+1/-2) include/unity/api/scopes/CMakeLists.txt (+3/-2) include/unity/api/scopes/ObjectProxy.h (+57/-0) include/unity/api/scopes/RegistryProxy.h (+83/-0) include/unity/api/scopes/ReplyBase.h (+76/-0) include/unity/api/scopes/ReplyProxy.h (+86/-0) include/unity/api/scopes/Runtime.h (+100/-0) include/unity/api/scopes/ScopeBase.h (+39/-25) include/unity/api/scopes/ScopeExceptions.h (+34/-0) include/unity/api/scopes/ScopeProxy.h (+80/-0) include/unity/api/scopes/Version.h.in (+23/-8) include/unity/api/scopes/internal/AbstractObject.h (+56/-0) include/unity/api/scopes/internal/CMakeLists.txt (+5/-0) include/unity/api/scopes/internal/ConfigBase.h (+68/-0) include/unity/api/scopes/internal/DynamicLoader.h (+17/-3) include/unity/api/scopes/internal/MWObject.h (+65/-0) include/unity/api/scopes/internal/MWObjectProxy.h (+66/-0) include/unity/api/scopes/internal/MWRegistryProxy.h (+61/-0) include/unity/api/scopes/internal/MWReplyProxy.h (+59/-0) include/unity/api/scopes/internal/MWScopeProxy.h (+57/-0) include/unity/api/scopes/internal/MiddlewareBase.h (+21/-5) include/unity/api/scopes/internal/MiddlewareFactory.h (+100/-0) include/unity/api/scopes/internal/MiddlewareFactoryConfig.h (+60/-0) include/unity/api/scopes/internal/ObjectProxyImpl.h (+57/-0) include/unity/api/scopes/internal/RegistryConfig.h (+64/-0) include/unity/api/scopes/internal/RegistryObject.h (+71/-0) include/unity/api/scopes/internal/RegistryProxyImpl.h (+66/-0) include/unity/api/scopes/internal/ReplyObject.h (+68/-0) include/unity/api/scopes/internal/ReplyProxyImpl.h (+68/-0) include/unity/api/scopes/internal/RuntimeConfig.h (+65/-0) include/unity/api/scopes/internal/RuntimeImpl.h (+72/-0) include/unity/api/scopes/internal/ScopeExceptionsImpl.h (+65/-0) include/unity/api/scopes/internal/ScopeLoader.h (+51/-11) include/unity/api/scopes/internal/ScopeLoader.h.bak (+96/-0) include/unity/api/scopes/internal/ScopeObject.h (+66/-0) include/unity/api/scopes/internal/ScopeProxyImpl.h (+61/-0) include/unity/api/scopes/internal/ice_middleware/CMakeLists.txt (+3/-0) include/unity/api/scopes/internal/ice_middleware/IceMiddleware.h (+85/-0) include/unity/api/scopes/internal/ice_middleware/IceObjectProxy.h (+67/-0) include/unity/api/scopes/internal/ice_middleware/IceRegistryProxy.h (+69/-0) include/unity/api/scopes/internal/ice_middleware/IceReplyProxy.h (+67/-0) include/unity/api/scopes/internal/ice_middleware/IceScopeProxy.h (+66/-0) include/unity/api/scopes/internal/ice_middleware/RegistryI.h (+72/-0) include/unity/api/scopes/internal/ice_middleware/ReplyI.h (+67/-0) include/unity/api/scopes/internal/ice_middleware/RethrowException.h (+55/-0) include/unity/api/scopes/internal/ice_middleware/ScopeI.h (+70/-0) slice/CMakeLists.txt (+4/-0) slice/unity/CMakeLists.txt (+4/-0) slice/unity/api/CMakeLists.txt (+4/-0) slice/unity/api/scopes/CMakeLists.txt (+4/-0) slice/unity/api/scopes/internal/CMakeLists.txt (+4/-0) slice/unity/api/scopes/internal/ice_middleware/CMakeLists.txt (+2/-0) slice/unity/api/scopes/internal/ice_middleware/Registry.ice (+52/-0) slice/unity/api/scopes/internal/ice_middleware/Reply.ice (+48/-0) slice/unity/api/scopes/internal/ice_middleware/Scope.ice (+49/-0) src/CMakeLists.txt (+0/-26) src/unity/api/scopes/CMakeLists.txt (+6/-0) src/unity/api/scopes/ObjectProxy.cpp (+46/-0) src/unity/api/scopes/RegistryProxy.cpp (+58/-0) src/unity/api/scopes/ReplyBase.cpp (+48/-0) src/unity/api/scopes/ReplyProxy.cpp (+59/-0) src/unity/api/scopes/Runtime.cpp (+68/-0) src/unity/api/scopes/ScopeBase.cpp (+13/-3) src/unity/api/scopes/ScopeExceptions.cpp (+36/-1) src/unity/api/scopes/ScopeProxy.cpp (+54/-0) src/unity/api/scopes/Version.cpp (+2/-1) src/unity/api/scopes/internal/AbstractObject.cpp (+47/-0) src/unity/api/scopes/internal/CMakeLists.txt (+31/-0) src/unity/api/scopes/internal/ConfigBase.cpp (+102/-0) src/unity/api/scopes/internal/DynamicLoader.cpp (+35/-4) src/unity/api/scopes/internal/Factory.ini.in (+4/-0) src/unity/api/scopes/internal/MWObject.cpp (+59/-0) src/unity/api/scopes/internal/MWObjectProxy.cpp (+58/-0) src/unity/api/scopes/internal/MWRegistryProxy.cpp (+50/-0) src/unity/api/scopes/internal/MWReplyProxy.cpp (+50/-0) src/unity/api/scopes/internal/MWScopeProxy.cpp (+50/-0) src/unity/api/scopes/internal/MiddlewareBase.cpp (+2/-0) src/unity/api/scopes/internal/MiddlewareFactory.cpp (+132/-0) src/unity/api/scopes/internal/MiddlewareFactoryConfig.cpp (+61/-0) src/unity/api/scopes/internal/Registry.config.in (+11/-0) src/unity/api/scopes/internal/Registry.ini.in (+4/-0) src/unity/api/scopes/internal/RegistryConfig.cpp (+82/-0) src/unity/api/scopes/internal/RegistryMain.cpp (+95/-0) src/unity/api/scopes/internal/RegistryObject.cpp (+115/-0) src/unity/api/scopes/internal/RegistryProxyImpl.cpp (+89/-0) src/unity/api/scopes/internal/ReplyObject.cpp (+157/-0) src/unity/api/scopes/internal/ReplyProxyImpl.cpp (+103/-0) src/unity/api/scopes/internal/RuntimeConfig.cpp (+93/-0) src/unity/api/scopes/internal/RuntimeImpl.cpp (+135/-0) src/unity/api/scopes/internal/ScopeExceptionsImpl.cpp (+67/-0) src/unity/api/scopes/internal/ScopeLoader.cpp (+291/-91) src/unity/api/scopes/internal/ScopeObject.cpp (+98/-0) src/unity/api/scopes/internal/ScopeProxyImpl.cpp (+93/-0) src/unity/api/scopes/internal/Scopes.ini.in (+16/-0) src/unity/api/scopes/internal/ice_middleware/CMakeLists.txt (+13/-0) src/unity/api/scopes/internal/ice_middleware/IceMiddleware.cpp (+292/-0) src/unity/api/scopes/internal/ice_middleware/IceObjectProxy.cpp (+62/-0) src/unity/api/scopes/internal/ice_middleware/IceRegistryProxy.cpp (+102/-0) src/unity/api/scopes/internal/ice_middleware/IceReplyProxy.cpp (+89/-0) src/unity/api/scopes/internal/ice_middleware/IceScopeProxy.cpp (+80/-0) src/unity/api/scopes/internal/ice_middleware/RegistryI.cpp (+99/-0) src/unity/api/scopes/internal/ice_middleware/ReplyI.cpp (+114/-0) src/unity/api/scopes/internal/ice_middleware/RethrowException.cpp (+56/-0) src/unity/api/scopes/internal/ice_middleware/ScopeI.cpp (+84/-0) test/gtest/unity/api/scopes/CMakeLists.txt (+2/-0) test/gtest/unity/api/scopes/Runtime/CMakeLists.txt (+9/-0) test/gtest/unity/api/scopes/Runtime/Factory.ini.in (+2/-0) test/gtest/unity/api/scopes/Runtime/Ice.Config.in (+4/-0) test/gtest/unity/api/scopes/Runtime/Registry.ini.in (+4/-0) test/gtest/unity/api/scopes/Runtime/Runtime_test.cpp (+31/-0) test/gtest/unity/api/scopes/Runtime/Scopes.ini.in (+5/-0) test/gtest/unity/api/scopes/ScopeBase/ScopeBase_test.cpp (+2/-7) test/gtest/unity/api/scopes/ScopeBase/scopelib.cpp (+7/-3) test/gtest/unity/api/scopes/ScopeExceptions/CMakeLists.txt (+4/-0) test/gtest/unity/api/scopes/ScopeExceptions/ScopeExceptions_test.cpp (+48/-0) test/gtest/unity/api/scopes/Version/Version_test.cpp (+1/-1) test/gtest/unity/api/scopes/internal/CMakeLists.txt (+5/-0) test/gtest/unity/api/scopes/internal/ConfigBase/CMakeLists.txt (+6/-0) test/gtest/unity/api/scopes/internal/ConfigBase/ConfigBase_test.cpp (+127/-0) test/gtest/unity/api/scopes/internal/ConfigBase/Test.ini.in (+6/-0) test/gtest/unity/api/scopes/internal/DynamicLoader/DynamicLoader_test.cpp (+2/-2) test/gtest/unity/api/scopes/internal/DynamicLoader/badtestlib.cpp (+14/-14) test/gtest/unity/api/scopes/internal/DynamicLoader/testlib.cpp (+8/-8) test/gtest/unity/api/scopes/internal/RegistryConfig/CMakeLists.txt (+6/-0) test/gtest/unity/api/scopes/internal/RegistryConfig/Registry.ini.in (+4/-0) test/gtest/unity/api/scopes/internal/RegistryConfig/RegistryConfig_test.cpp (+51/-0) test/gtest/unity/api/scopes/internal/RuntimeConfig/BadMW.ini.in (+5/-0) test/gtest/unity/api/scopes/internal/RuntimeConfig/BadRegID.ini.in (+5/-0) test/gtest/unity/api/scopes/internal/RuntimeConfig/CMakeLists.txt (+12/-0) test/gtest/unity/api/scopes/internal/RuntimeConfig/FacFileEmpty.ini.in (+5/-0) test/gtest/unity/api/scopes/internal/RuntimeConfig/MWEmpty.ini.in (+5/-0) test/gtest/unity/api/scopes/internal/RuntimeConfig/RegFileEmpty.ini.in (+5/-0) test/gtest/unity/api/scopes/internal/RuntimeConfig/RegIDEmpty.ini.in (+5/-0) test/gtest/unity/api/scopes/internal/RuntimeConfig/RuntimeConfig_test.cpp (+121/-0) test/gtest/unity/api/scopes/internal/RuntimeConfig/Scopes.ini.in (+5/-0) test/gtest/unity/api/scopes/internal/RuntimeImpl/CMakeLists.txt (+9/-0) test/gtest/unity/api/scopes/internal/RuntimeImpl/Factory.ini.in (+2/-0) test/gtest/unity/api/scopes/internal/RuntimeImpl/Ice.Config.in (+4/-0) test/gtest/unity/api/scopes/internal/RuntimeImpl/Registry.ini.in (+4/-0) test/gtest/unity/api/scopes/internal/RuntimeImpl/RuntimeImpl_test.cpp (+77/-0) test/gtest/unity/api/scopes/internal/RuntimeImpl/Scopes.ini.in (+5/-0) test/gtest/unity/api/scopes/internal/ScopeLoader/BadVersion.cpp (+75/-0) test/gtest/unity/api/scopes/internal/ScopeLoader/CMakeLists.txt (+8/-3) test/gtest/unity/api/scopes/internal/ScopeLoader/Counters.cpp (+14/-0) test/gtest/unity/api/scopes/internal/ScopeLoader/Counters.h (+3/-0) test/gtest/unity/api/scopes/internal/ScopeLoader/Ice.Config.in (+8/-0) test/gtest/unity/api/scopes/internal/ScopeLoader/MyScope.h (+22/-4) test/gtest/unity/api/scopes/internal/ScopeLoader/NoDestroy.cpp (+10/-11) test/gtest/unity/api/scopes/internal/ScopeLoader/NullReturn.cpp (+23/-21) test/gtest/unity/api/scopes/internal/ScopeLoader/ScopeA.cpp (+30/-23) test/gtest/unity/api/scopes/internal/ScopeLoader/ScopeB.cpp (+30/-23) test/gtest/unity/api/scopes/internal/ScopeLoader/ScopeLoader_test.cpp (+377/-90) test/gtest/unity/api/scopes/internal/ScopeLoader/TestScope.cpp (+18/-19) test/gtest/unity/api/scopes/internal/ScopeLoader/ThrowStdExFromStop.cpp (+24/-21) test/gtest/unity/api/scopes/internal/ScopeLoader/ThrowUnityExFromRun.cpp (+60/-0) test/gtest/unity/api/scopes/internal/ScopeLoader/ThrowUnityExFromStart.cpp (+25/-22) test/gtest/unity/api/scopes/internal/ScopeLoader/ThrowUnityExFromStop.cpp (+25/-22) test/gtest/unity/api/scopes/internal/ScopeLoader/ThrowUnknownExFromStart.cpp (+59/-0) test/gtest/unity/api/scopes/internal/ScopeLoader/ThrowUnknownExFromStop.cpp (+24/-21) test/gtest/unity/api/scopes/internal/ice_middleware/CMakeLists.txt (+6/-0) test/gtest/unity/api/scopes/internal/ice_middleware/Ice.config.in (+5/-0) test/gtest/unity/api/scopes/internal/ice_middleware/IceMiddleware_test.cpp (+34/-0) test/headers/CMakeLists.txt (+1/-1) test/headers/includechecker.py (+1/-0) valgrind-suppress (+75/-0) |
To merge this branch: | bzr merge lp:~michihenning/unity-scopes-api/valgrind-suppressions |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Unity Team | Pending | ||
Review via email:
|
Commit message
Added valgrind suppressions for various bogus possible leak reports.
Description of the change
Added valgrind suppressions for various bogus possible leak reports.
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'CMakeLists.txt' |
2 | --- CMakeLists.txt 2013-07-04 00:39:02 +0000 |
3 | +++ CMakeLists.txt 2013-08-05 06:40:36 +0000 |
4 | @@ -15,26 +15,6 @@ |
5 | |
6 | string(TOLOWER "${CMAKE_BUILD_TYPE}" cmake_build_type_lower) # Build types should always be lowercase but sometimes they are not. |
7 | |
8 | -include(EnableCoverageReport) |
9 | -##################################################################### |
10 | -# Enable code coverage calculation with gcov/gcovr/lcov |
11 | -# Usage: |
12 | -# * Switch build type to coverage (use ccmake or cmake-gui) |
13 | -# * Invoke make, make test, make coverage (or ninja if you use that backend) |
14 | -# * Find html report in subdir coveragereport |
15 | -# * Find xml report suitable for jenkins in coverage.xml |
16 | -##################################################################### |
17 | -if(cmake_build_type_lower MATCHES coverage) |
18 | - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage") |
19 | - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --coverage") |
20 | - set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} --coverage") |
21 | - set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} --coverage") |
22 | - |
23 | - # We add -g when building with coverage so valgrind reports line numbers. |
24 | - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g" ) |
25 | - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g" ) |
26 | -endif() |
27 | - |
28 | # Static C++ checks |
29 | |
30 | find_program(CPPCHECK_COMMAND NAMES cppcheck) |
31 | @@ -66,6 +46,16 @@ |
32 | message(WARNING "Cannot find valgrind: valgrind target will not be available") |
33 | endif() |
34 | |
35 | +# TODO: For now, we need to use Ice 3.5 built from source until the Debian package becomes available. |
36 | +# The tarball is available here: http://zeroc.com/download/Ice/3.5/Ice-3.5.0.tar.gz |
37 | +# To build Ice, go to <source_root>/cpp, and do "make; make test; sudo make install". |
38 | +# The default config is fine. If you want to install somewhere else, edit the cpp/config/Make.rules file. |
39 | +set(IceRoot /usr) |
40 | +if (NOT EXISTS ${IceRoot}/include/Ice/Ice.h) |
41 | + message(FATAL_ERROR "Cannot find Ice development files. You need to build Ice 3.5 from source and install it, and set IceRoot in CMakeLists.txt accordingly. Then set LD_LIBRARY_PATH to include the Ice lib64 directory, set PATH to include the Ice bin directory, and try again.") |
42 | +endif() |
43 | + |
44 | +set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L${IceRoot}/lib64") |
45 | |
46 | include(FindPkgConfig) |
47 | find_package(Boost 1.49.0 COMPONENTS regex REQUIRED) |
48 | @@ -73,12 +63,17 @@ |
49 | set(OTHER_INCLUDE_DIRS ${OTHER_INCLUDE_DIRS} ${UNITY_API_INCLUDE_DIRS}) |
50 | set(OTHER_LIBS ${OTHER_LIBS} ${UNITY_API_LDFLAGS}) |
51 | |
52 | +# UNIX Domain Socket transport plug-in for Ice. |
53 | +pkg_check_modules(IceUDS libIceUDS REQUIRED) |
54 | + |
55 | # Standard install paths |
56 | include(GNUInstallDirs) |
57 | |
58 | include_directories( |
59 | ${CMAKE_SOURCE_DIR}/include |
60 | ${CMAKE_BINARY_DIR}/include |
61 | + ${CMAKE_BINARY_DIR} |
62 | + ${IceRoot}/include |
63 | ${OTHER_INCLUDE_DIRS} |
64 | ) |
65 | |
66 | @@ -87,7 +82,13 @@ |
67 | # Exported functions and classes are prefixed by a UNITY_API macro, |
68 | # which explicitly exports a symbol if UNITY_DLL_EXPORTS is defined. |
69 | add_definitions(-DUNITY_DLL_EXPORTS) |
70 | -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden") |
71 | + |
72 | +# TODO: static linking of the tests doesn't work because the tests won't pull in virtual methods in a |
73 | +# base class from a static library without an unresolved dependency. But, without static linking, we can't |
74 | +# do whitebox tests because of the visibility=hidden compile flags. For now, we link dynamically and |
75 | +# with visbility=default. |
76 | +#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden") |
77 | +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=default") # HACK |
78 | |
79 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fno-permissive -pedantic -Wall -Wextra") |
80 | |
81 | @@ -105,7 +106,6 @@ |
82 | set(UNITY_SCOPES_MAJOR 0) |
83 | set(UNITY_SCOPES_MINOR 1) |
84 | set(UNITY_SCOPES_MICRO 0) |
85 | -set(UNITY_SCOPES_VERSION "${UNITY_SCOPES_MAJOR}.${UNITY_SCOPES_MINOR}.${UNITY_SCOPES_MICRO}") |
86 | |
87 | # Scopes library |
88 | set(UNITY_SCOPES_LIB unity-scopes) |
89 | @@ -117,7 +117,10 @@ |
90 | set(OTHER_LIBS |
91 | ${OTHER_LIBS} |
92 | unity-api |
93 | + Ice |
94 | + IceUtil |
95 | dl |
96 | + pthread |
97 | ) |
98 | |
99 | # All the libraries we need to link a normal executable that uses Unity scopes |
100 | @@ -125,7 +128,14 @@ |
101 | |
102 | # All the libraries we need to link a gtest executable. (We link the tests against a static version |
103 | # so we can do whitebox testing on internal classes. |
104 | -set(TESTLIBS ${UNITY_SCOPES_STATIC_LIB} ${OTHER_LIBS}) |
105 | + |
106 | +# TODO: HACK: static linking of the tests doesn't work because the tests won't pull in virtual methods in a |
107 | +# base class from a static library without an unresolved dependency. But, without static linking, we can't |
108 | +# do whitebox tests because of the visibility=hidden compile flags. For now, we link dynamically and |
109 | +# with visbility=default. |
110 | + |
111 | +# set(TESTLIBS ${UNITY_SCOPES_STATIC_LIB} ${OTHER_LIBS}) |
112 | +set(TESTLIBS ${UNITY_SCOPES_LIB} ${OTHER_LIBS}) # HACK |
113 | |
114 | # Library install prefix |
115 | set(LIB_INSTALL_PREFIX lib/${CMAKE_LIBRARY_ARCHITECTURE}) |
116 | @@ -136,10 +146,91 @@ |
117 | include(CTest) |
118 | enable_testing() |
119 | |
120 | -# add subdirectories to build |
121 | +# Add subdirectories. |
122 | add_subdirectory(include) |
123 | add_subdirectory(src) |
124 | add_subdirectory(test) |
125 | +add_subdirectory(slice) |
126 | +add_subdirectory(demo) |
127 | + |
128 | +# Custom rules to compile Slice files |
129 | +foreach(file ${SLICE_FILES}) |
130 | + |
131 | + string(REPLACE "${CMAKE_SOURCE_DIR}" "${CMAKE_BINARY_DIR}" build_dir ${file}) |
132 | + get_filename_component(build_dir ${build_dir} PATH) |
133 | + |
134 | + get_filename_component(slice_file ${file} NAME) |
135 | + string(REPLACE ".ice" ".cpp" src_file ${slice_file}) |
136 | + string(REPLACE ".ice" ".h" hdr_file ${slice_file}) |
137 | + |
138 | + set(src_file ${build_dir}/${src_file}) |
139 | + set(hdr_file ${build_dir}/${hdr_file}) |
140 | + |
141 | + string(REPLACE "${CMAKE_BINARY_DIR}/" "" relative_build_dir ${build_dir}) |
142 | + |
143 | + add_custom_command(OUTPUT ${src_file} ${hdr_file} |
144 | + DEPENDS ${file} |
145 | + COMMAND slice2cpp --output-dir=${build_dir} --include-dir ${relative_build_dir} ${file}) |
146 | + |
147 | + set(SLICE_HDRS ${SLICE_HDRS} ${hdr_file}) |
148 | + set(SLICE_SRC ${SLICE_SRC} ${src_file}) |
149 | +endforeach() |
150 | + |
151 | +# Set up coverage testing |
152 | +include(EnableCoverageReport) |
153 | +##################################################################### |
154 | +# Enable code coverage calculation with gcov/gcovr/lcov |
155 | +# Usage: |
156 | +# * Switch build type to coverage (use ccmake or cmake-gui) |
157 | +# * Invoke make, make test, make coverage (or ninja if you use that backend) |
158 | +# * Find html report in subdir coveragereport |
159 | +# * Find xml report suitable for jenkins in coverage.xml |
160 | +##################################################################### |
161 | +if(cmake_build_type_lower MATCHES coverage) |
162 | + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage") |
163 | + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --coverage") |
164 | + set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} --coverage") |
165 | + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} --coverage") |
166 | + set(CMAKE_STATIC_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} --coverage") |
167 | + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} --coverage") |
168 | + |
169 | + # We add -g when building with coverage so valgrind reports line numbers. |
170 | + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g" ) |
171 | + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g" ) |
172 | +endif() |
173 | + |
174 | +# Pseudo-library of object files. We need a dynamic version of the library for normal clients, |
175 | +# and a static version for the whitebox tests, so we can write unit tests for classes in the internal namespaces |
176 | +# (because, for the .so, non-public APIs are compiled with -fvisibility=hidden). |
177 | +# Everything is compiled with -fPIC, so the same object files are suitable for either library. |
178 | +# Here, we create an object library that then is used to link the static and dynamic |
179 | +# libraries, without having to compile each source file twice with different compile flags. |
180 | + |
181 | +set(UNITY_SCOPES_LIB_OBJ ${UNITY_SCOPES_LIB}-obj) |
182 | +add_library(${UNITY_SCOPES_LIB_OBJ} OBJECT ${UNITY_SCOPES_LIB_SRC} ${SLICE_SRC}) |
183 | +set_target_properties(${UNITY_SCOPES_LIB_OBJ} PROPERTIES COMPILE_FLAGS "-fPIC") |
184 | + |
185 | +# Use the object files to make the shared library. |
186 | +set(UNITY_SCOPES_SOVERSION 0) |
187 | +add_library(${UNITY_SCOPES_LIB} SHARED $<TARGET_OBJECTS:${UNITY_SCOPES_LIB_OBJ}>) |
188 | +set_target_properties(${UNITY_SCOPES_LIB} PROPERTIES |
189 | + VERSION "${UNITY_SCOPES_MAJOR}.${UNITY_SCOPES_MINOR}" |
190 | + SOVERSION ${UNITY_SCOPES_SOVERSION} |
191 | +) |
192 | + |
193 | +# Use the object files to make the static library. |
194 | +add_library(${UNITY_SCOPES_STATIC_LIB} STATIC $<TARGET_OBJECTS:${UNITY_SCOPES_LIB_OBJ}>) |
195 | +set_target_properties(${UNITY_SCOPES_STATIC_LIB} PROPERTIES OUTPUT_NAME ${UNITY_SCOPES_LIB}) |
196 | + |
197 | +# Only the dynamic library gets installed. |
198 | +install(TARGETS ${UNITY_SCOPES_LIB} LIBRARY DESTINATION ${LIB_INSTALL_PREFIX}) |
199 | + |
200 | +set_target_properties(${UNITY_SCOPES_LIB} PROPERTIES |
201 | + VERSION "${UNITY_SCOPES_MAJOR}.${UNITY_SCOPES_MINOR}" |
202 | + SOVERSION ${UNITY_SCOPES_SOVERSION} |
203 | +) |
204 | + |
205 | +# Enable coverage testing |
206 | |
207 | if (cmake_build_type_lower MATCHES coverage) |
208 | ENABLE_COVERAGE_REPORT(TARGETS ${UNITY_SCOPES_LIB} FILTER /usr/include ${CMAKE_SOURCE_DIR}/test/* ${CMAKE_BINARY_DIR}/*) |
209 | |
210 | === added directory 'demo' |
211 | === added file 'demo/CMakeLists.txt' |
212 | --- demo/CMakeLists.txt 1970-01-01 00:00:00 +0000 |
213 | +++ demo/CMakeLists.txt 2013-08-05 06:40:36 +0000 |
214 | @@ -0,0 +1,18 @@ |
215 | +add_library(scope-A MODULE scope-A.cpp) |
216 | +add_library(scope-B MODULE scope-B.cpp) |
217 | +add_library(scope-C MODULE scope-C.cpp) |
218 | +add_library(scope-D MODULE scope-D.cpp) |
219 | + |
220 | +add_executable(scoperunner-A scoperunner-A.cpp) |
221 | +target_link_libraries(scoperunner-A ${UNITY_SCOPES_LIB} ${OTHER_LIBS}) |
222 | + |
223 | +add_executable(scoperunner-BC scoperunner-BC.cpp) |
224 | +target_link_libraries(scoperunner-BC ${UNITY_SCOPES_LIB} ${OTHER_LIBS}) |
225 | + |
226 | +add_executable(scoperunner-D scoperunner-D.cpp) |
227 | +target_link_libraries(scoperunner-D ${UNITY_SCOPES_LIB} ${OTHER_LIBS}) |
228 | + |
229 | +add_executable(client client.cpp) |
230 | +target_link_libraries(client ${UNITY_SCOPES_LIB} ${OTHER_LIBS}) |
231 | + |
232 | +configure_file(Ice.Config.in ${CMAKE_CURRENT_BINARY_DIR}/Ice.Config) |
233 | |
234 | === added file 'demo/Ice.Config.in' |
235 | --- demo/Ice.Config.in 1970-01-01 00:00:00 +0000 |
236 | +++ demo/Ice.Config.in 2013-08-05 06:40:36 +0000 |
237 | @@ -0,0 +1,9 @@ |
238 | +Ice.Plugin.IceUDS.cpp.IceUDS=@IceUDS_LIBDIR@/IceUDS,1.0:create_Ice_UDS |
239 | +scope-A.Endpoints=uds -f /tmp/scope-A |
240 | +scope-B.Endpoints=uds -f /tmp/scope-B |
241 | +scope-C.Endpoints=uds -f /tmp/scope-C |
242 | +scope-D.Endpoints=uds -f /tmp/scope-D |
243 | + |
244 | +Ice.Trace.Network=3 |
245 | +#Ice.Trace.Protocol=1 |
246 | +Ice.Warn.UnusedProperties=1 |
247 | |
248 | === added file 'demo/client.cpp' |
249 | --- demo/client.cpp 1970-01-01 00:00:00 +0000 |
250 | +++ demo/client.cpp 2013-08-05 06:40:36 +0000 |
251 | @@ -0,0 +1,106 @@ |
252 | +/* |
253 | + * Copyright (C) 2013 Canonical Ltd |
254 | + * |
255 | + * This program is free software: you can redistribute it and/or modify |
256 | + * it under the terms of the GNU General Public License version 3 as |
257 | + * published by the Free Software Foundation. |
258 | + * |
259 | + * This program is distributed in the hope that it will be useful, |
260 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
261 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
262 | + * GNU General Public License for more details. |
263 | + * |
264 | + * You should have received a copy of the GNU General Public License |
265 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
266 | + * |
267 | + * Authored by: Michi Henning <michi.henning@canonical.com> |
268 | + */ |
269 | + |
270 | +#include <unity/api/scopes/RegistryProxy.h> |
271 | +#include <unity/api/scopes/Runtime.h> |
272 | +#include <unity/api/scopes/ReplyProxy.h> |
273 | +#include <unity/UnityExceptions.h> |
274 | + |
275 | +#include <condition_variable> |
276 | +#include <iostream> |
277 | +#include <mutex> |
278 | + |
279 | +using namespace std; |
280 | +using namespace unity::api::scopes; |
281 | + |
282 | +class Reply : public ReplyBase |
283 | +{ |
284 | +public: |
285 | + virtual void send(string const& result) |
286 | + { |
287 | + cout << "received result: " << result << endl; |
288 | + } |
289 | + |
290 | + virtual void finished() |
291 | + { |
292 | + cout << "query complete" << endl; |
293 | + { |
294 | + unique_lock<decltype(mutex_)> lock(mutex_); |
295 | + query_complete_ = true; |
296 | + } |
297 | + condvar_.notify_one(); |
298 | + } |
299 | + |
300 | + void wait_until_finished() |
301 | + { |
302 | + unique_lock<decltype(mutex_)> lock(mutex_); |
303 | + condvar_.wait(lock, [this] { return this->query_complete_; }); |
304 | + } |
305 | + |
306 | + Reply() : |
307 | + query_complete_(false) |
308 | + { |
309 | + } |
310 | + |
311 | +private: |
312 | + bool query_complete_; |
313 | + mutex mutex_; |
314 | + condition_variable condvar_; |
315 | +}; |
316 | + |
317 | +int main(int argc, char* argv[]) |
318 | +{ |
319 | + if (argc != 3) |
320 | + { |
321 | + cerr << "usage: ./client <scope-letter> query" << endl; |
322 | + cerr << "For example: ./client B iron" << endl; |
323 | + return 1; |
324 | + } |
325 | + |
326 | + string scope_name = string("scope-") + argv[1]; |
327 | + string search_string = argv[2]; |
328 | + |
329 | + try |
330 | + { |
331 | + Runtime::UPtr rt = Runtime::create(""); |
332 | + |
333 | + RegistryProxy::SPtr r = rt->registry(); |
334 | + if (!r) |
335 | + { |
336 | + cerr << "could not get proxy for registry" << endl; |
337 | + return 1; |
338 | + } |
339 | + ScopeProxy::SPtr s = r->find(scope_name); |
340 | + if (!s) |
341 | + { |
342 | + cerr << "no such scope: " << scope_name << endl; |
343 | + return 1; |
344 | + } |
345 | + shared_ptr<Reply> reply(new Reply); |
346 | + s->query(search_string, reply); // Asynchronous, returns without waiting for query to be received by target. |
347 | + reply->wait_until_finished(); |
348 | + } |
349 | + |
350 | + catch (unity::Exception const& e) |
351 | + { |
352 | + cerr << e.to_string() << endl; |
353 | + return 1; |
354 | + } |
355 | + |
356 | + return 0; |
357 | +} |
358 | |
359 | === added file 'demo/scope-A.cpp' |
360 | --- demo/scope-A.cpp 1970-01-01 00:00:00 +0000 |
361 | +++ demo/scope-A.cpp 2013-08-05 06:40:36 +0000 |
362 | @@ -0,0 +1,69 @@ |
363 | +/* |
364 | + * Copyright (C) 2013 Canonical Ltd |
365 | + * |
366 | + * This program is free software: you can redistribute it and/or modify |
367 | + * it under the terms of the GNU General Public License version 3 as |
368 | + * published by the Free Software Foundation. |
369 | + * |
370 | + * This program is distributed in the hope that it will be useful, |
371 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
372 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
373 | + * GNU General Public License for more details. |
374 | + * |
375 | + * You should have received a copy of the GNU General Public License |
376 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
377 | + * |
378 | + * Authored by: Michi Henning <michi.henning@canonical.com> |
379 | + */ |
380 | + |
381 | +#include <unity/api/scopes/ScopeBase.h> |
382 | + |
383 | +#include <iostream> |
384 | + |
385 | +#define EXPORT __attribute__ ((visibility ("default"))) |
386 | + |
387 | +using namespace std; |
388 | +using namespace unity::api::scopes; |
389 | + |
390 | +// Example scope A: replies synchronously to a query. (Replies are returned before returning from the query() method.) |
391 | + |
392 | +class MyScope : public ScopeBase |
393 | +{ |
394 | +public: |
395 | + virtual int start(RegistryProxy::SPtr const&) override |
396 | + { |
397 | + return VERSION; |
398 | + } |
399 | + virtual void stop() override {} |
400 | + virtual void run() override {} |
401 | + virtual void query(string const& q, ReplyProxy::SPtr const& reply) override |
402 | + { |
403 | + cout << "scope-A: received query string \"" << q << "\"" << endl; |
404 | + |
405 | + reply->send("scope-A: result 1 for query \"" + q + "\""); |
406 | + reply->finished(); // Optional |
407 | + |
408 | + cout << "scope-A: query \"" << q << "\" complete" << endl; |
409 | + } |
410 | +}; |
411 | + |
412 | +extern "C" |
413 | +{ |
414 | + |
415 | + EXPORT |
416 | + unity::api::scopes::ScopeBase* |
417 | + // cppcheck-suppress unusedFunction |
418 | + UNITY_API_SCOPE_CREATE_FUNCTION() |
419 | + { |
420 | + return new MyScope; |
421 | + } |
422 | + |
423 | + EXPORT |
424 | + void |
425 | + // cppcheck-suppress unusedFunction |
426 | + UNITY_API_SCOPE_DESTROY_FUNCTION(unity::api::scopes::ScopeBase* scope_base) |
427 | + { |
428 | + delete scope_base; |
429 | + } |
430 | + |
431 | +} |
432 | |
433 | === added file 'demo/scope-B.cpp' |
434 | --- demo/scope-B.cpp 1970-01-01 00:00:00 +0000 |
435 | +++ demo/scope-B.cpp 2013-08-05 06:40:36 +0000 |
436 | @@ -0,0 +1,128 @@ |
437 | +/* |
438 | + * Copyright (C) 2013 Canonical Ltd |
439 | + * |
440 | + * This program is free software: you can redistribute it and/or modify |
441 | + * it under the terms of the GNU General Public License version 3 as |
442 | + * published by the Free Software Foundation. |
443 | + * |
444 | + * This program is distributed in the hope that it will be useful, |
445 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
446 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
447 | + * GNU General Public License for more details. |
448 | + * |
449 | + * You should have received a copy of the GNU General Public License |
450 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
451 | + * |
452 | + * Authored by: Michi Henning <michi.henning@canonical.com> |
453 | + */ |
454 | + |
455 | +#include <unity/api/scopes/ScopeBase.h> |
456 | +#include <unity/UnityExceptions.h> |
457 | + |
458 | +#include <iostream> |
459 | + |
460 | +#define EXPORT __attribute__ ((visibility ("default"))) |
461 | + |
462 | +using namespace std; |
463 | +using namespace unity::api::scopes; |
464 | + |
465 | +// Example scope B: aggregates from scope C and D. |
466 | + |
467 | +// A Reply instance remembers the query string and the reply object that was passed |
468 | +// from upstream. Results from the child scopes are sent to that upstream reply object. |
469 | + |
470 | +class Reply : public ReplyBase |
471 | +{ |
472 | +public: |
473 | + virtual void send(string const& result) override |
474 | + { |
475 | + cout << "received result from " << scope_name_ << ": " << result << endl; |
476 | + upstream_->send(result); |
477 | + } |
478 | + |
479 | + virtual void finished() override |
480 | + { |
481 | + cout << "query to " << scope_name_ << " complete" << endl; |
482 | + } |
483 | + |
484 | + Reply(string const& scope_name, ReplyProxy::SPtr const& upstream) : |
485 | + scope_name_(scope_name), |
486 | + upstream_(upstream) |
487 | + { |
488 | + } |
489 | + |
490 | +private: |
491 | + string scope_name_; |
492 | + ReplyProxy::SPtr upstream_; |
493 | +}; |
494 | + |
495 | +// MyScope agregates from C and D. |
496 | + |
497 | +class MyScope : public ScopeBase |
498 | +{ |
499 | +public: |
500 | + virtual int start(RegistryProxy::SPtr const& registry) override |
501 | + { |
502 | + // Lock up scopes C and D in the registry and remember their proxies. |
503 | + scope_c_ = registry->find("scope-C"); |
504 | + if (!scope_c_) |
505 | + { |
506 | + throw unity::ResourceException("Cannot locate scope-C in registry"); |
507 | + } |
508 | + scope_d_ = registry->find("scope-D"); |
509 | + if (!scope_d_) |
510 | + { |
511 | + throw unity::ResourceException("Cannot locate scope-D in registry"); |
512 | + } |
513 | + return VERSION; |
514 | + } |
515 | + |
516 | + virtual void stop() override {} |
517 | + virtual void run() override {} |
518 | + |
519 | + virtual void query(string const& q, ReplyProxy::SPtr const& reply) override |
520 | + { |
521 | + cout << "scope-B: received query string \"" << q << "\"" << endl; |
522 | + cout << "scope-B: forwarding query to scope-C and scope-D" << endl; |
523 | + |
524 | + shared_ptr<Reply> r; |
525 | + |
526 | + // Make a Reply instance and forward the query to C. C will deliver its |
527 | + // results to that Reply instance. |
528 | + r.reset(new Reply("scope-C", reply)); |
529 | + scope_c_->query(q, r); |
530 | + |
531 | + // Do the same thing for D. |
532 | + r.reset(new Reply("scope-D", reply)); |
533 | + scope_d_->query(q, r); |
534 | + |
535 | + // We are done. As the replies trickle in, the two reply instance (kept alive by our run time) |
536 | + // forward the results upstream. |
537 | + cout << "scope-B: query \"" << q << "\" complete" << endl; |
538 | + } |
539 | + |
540 | +private: |
541 | + ScopeProxy::SPtr scope_c_; |
542 | + ScopeProxy::SPtr scope_d_; |
543 | +}; |
544 | + |
545 | +extern "C" |
546 | +{ |
547 | + |
548 | + EXPORT |
549 | + unity::api::scopes::ScopeBase* |
550 | + // cppcheck-suppress unusedFunction |
551 | + UNITY_API_SCOPE_CREATE_FUNCTION() |
552 | + { |
553 | + return new MyScope; |
554 | + } |
555 | + |
556 | + EXPORT |
557 | + void |
558 | + // cppcheck-suppress unusedFunction |
559 | + UNITY_API_SCOPE_DESTROY_FUNCTION(unity::api::scopes::ScopeBase* scope_base) |
560 | + { |
561 | + delete scope_base; |
562 | + } |
563 | + |
564 | +} |
565 | |
566 | === added file 'demo/scope-C.cpp' |
567 | --- demo/scope-C.cpp 1970-01-01 00:00:00 +0000 |
568 | +++ demo/scope-C.cpp 2013-08-05 06:40:36 +0000 |
569 | @@ -0,0 +1,104 @@ |
570 | +/* |
571 | + * Copyright (C) 2013 Canonical Ltd |
572 | + * |
573 | + * This program is free software: you can redistribute it and/or modify |
574 | + * it under the terms of the GNU General Public License version 3 as |
575 | + * published by the Free Software Foundation. |
576 | + * |
577 | + * This program is distributed in the hope that it will be useful, |
578 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
579 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
580 | + * GNU General Public License for more details. |
581 | + * |
582 | + * You should have received a copy of the GNU General Public License |
583 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
584 | + * |
585 | + * Authored by: Michi Henning <michi.henning@canonical.com> |
586 | + */ |
587 | + |
588 | +#include <unity/api/scopes/ScopeBase.h> |
589 | + |
590 | +#include <condition_variable> |
591 | +#include <iostream> |
592 | +#include <list> |
593 | +#include <mutex> |
594 | + |
595 | +#define EXPORT __attribute__ ((visibility ("default"))) |
596 | + |
597 | +using namespace std; |
598 | +using namespace unity::api::scopes; |
599 | + |
600 | +// Example scope C: replies asynchronously to a query from a worker thread. |
601 | + |
602 | +class MyScope : public ScopeBase |
603 | +{ |
604 | +public: |
605 | + virtual int start(RegistryProxy::SPtr const&) override |
606 | + { |
607 | + return VERSION; |
608 | + } |
609 | + |
610 | + virtual void stop() override {} |
611 | + |
612 | + virtual void run() override |
613 | + { |
614 | + // Worker thread: gets queries from the queue and processes them. |
615 | + for (;;) |
616 | + { |
617 | + std::unique_lock<std::mutex> lock(mutex_); |
618 | + condvar_.wait(lock, [this] { return !queries_.empty(); }); // Wait until we have a query |
619 | + |
620 | + auto qd = queries_.front(); |
621 | + queries_.pop_front(); |
622 | + qd.reply_proxy->send("scope-C: result 1 for query \"" + qd.query + "\""); |
623 | + qd.reply_proxy->send("scope-C: result 2 for query \"" + qd.query + "\""); |
624 | + qd.reply_proxy->send("scope-C: result 3 for query \"" + qd.query + "\""); |
625 | + qd.reply_proxy->finished(); |
626 | + |
627 | + cout << "scope-C: query \"" << qd.query << "\" complete" << endl; |
628 | + } |
629 | + } |
630 | + |
631 | + virtual void query(string const& q, ReplyProxy::SPtr const& reply) override |
632 | + { |
633 | + cout << "scope-C: received query string \"" << q << "\"" << endl; |
634 | + { |
635 | + // Add query to queue |
636 | + std::lock_guard<std::mutex> lock(mutex_); |
637 | + QueryData qd = { q, reply }; |
638 | + queries_.push_back(qd); |
639 | + } |
640 | + condvar_.notify_one(); // Wake up worker thread. |
641 | + } |
642 | + |
643 | +private: |
644 | + struct QueryData |
645 | + { |
646 | + std::string query; |
647 | + ReplyProxy::SPtr reply_proxy; |
648 | + }; |
649 | + std::list<QueryData> queries_; |
650 | + std::mutex mutex_; |
651 | + std::condition_variable condvar_; |
652 | +}; |
653 | + |
654 | +extern "C" |
655 | +{ |
656 | + |
657 | + EXPORT |
658 | + unity::api::scopes::ScopeBase* |
659 | + // cppcheck-suppress unusedFunction |
660 | + UNITY_API_SCOPE_CREATE_FUNCTION() |
661 | + { |
662 | + return new MyScope; |
663 | + } |
664 | + |
665 | + EXPORT |
666 | + void |
667 | + // cppcheck-suppress unusedFunction |
668 | + UNITY_API_SCOPE_DESTROY_FUNCTION(unity::api::scopes::ScopeBase* scope_base) |
669 | + { |
670 | + delete scope_base; |
671 | + } |
672 | + |
673 | +} |
674 | |
675 | === added file 'demo/scope-D.cpp' |
676 | --- demo/scope-D.cpp 1970-01-01 00:00:00 +0000 |
677 | +++ demo/scope-D.cpp 2013-08-05 06:40:36 +0000 |
678 | @@ -0,0 +1,103 @@ |
679 | +/* |
680 | + * Copyright (C) 2013 Canonical Ltd |
681 | + * |
682 | + * This program is free software: you can redistribute it and/or modify |
683 | + * it under the terms of the GNU General Public License version 3 as |
684 | + * published by the Free Software Foundation. |
685 | + * |
686 | + * This program is distributed in the hope that it will be useful, |
687 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
688 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
689 | + * GNU General Public License for more details. |
690 | + * |
691 | + * You should have received a copy of the GNU General Public License |
692 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
693 | + * |
694 | + * Authored by: Michi Henning <michi.henning@canonical.com> |
695 | + */ |
696 | + |
697 | +#include <unity/api/scopes/ScopeBase.h> |
698 | + |
699 | +#include <condition_variable> |
700 | +#include <iostream> |
701 | +#include <list> |
702 | +#include <mutex> |
703 | + |
704 | +#define EXPORT __attribute__ ((visibility ("default"))) |
705 | + |
706 | +using namespace std; |
707 | +using namespace unity::api::scopes; |
708 | + |
709 | +// Example scope D: replies asynchronously to a query. (Replies are returned after returning from the query() method.) |
710 | +// Same as scope C, but does not make the call to finished() to show that this happens automatically when |
711 | +// the reply proxy goes out of scope. |
712 | + |
713 | +class MyScope : public ScopeBase |
714 | +{ |
715 | +public: |
716 | + virtual int start(RegistryProxy::SPtr const&) override |
717 | + { |
718 | + return VERSION; |
719 | + } |
720 | + virtual void stop() override {} |
721 | + virtual void run() override |
722 | + { |
723 | + for (;;) |
724 | + { |
725 | + std::unique_lock<std::mutex> lock(mutex_); |
726 | + condvar_.wait(lock, [this] { return !queries_.empty(); }); |
727 | + auto qd = queries_.front(); |
728 | + queries_.pop_front(); |
729 | + qd.reply_proxy->send("scope-D: result 1 for query \"" + qd.query + "\""); |
730 | + qd.reply_proxy->send("scope-D: result 2 for query \"" + qd.query + "\""); |
731 | + qd.reply_proxy->send("scope-D: result 3 for query \"" + qd.query + "\""); |
732 | + qd.reply_proxy->send("scope-D: result 4 for query \"" + qd.query + "\""); |
733 | + // qd.reply_proxy->finished(); |
734 | + // Call to finished() commented out here, just to show that it happens automatically. |
735 | + |
736 | + cout << "scope-D: query \"" << qd.query << "\" complete" << endl; |
737 | + } |
738 | + } |
739 | + |
740 | + virtual void query(string const& q, ReplyProxy::SPtr const& reply) override |
741 | + { |
742 | + cout << "scope-D: received query string \"" << q << "\"" << endl; |
743 | + { |
744 | + std::lock_guard<std::mutex> lock(mutex_); |
745 | + QueryData qd = { q, reply }; |
746 | + queries_.push_back(qd); |
747 | + } |
748 | + condvar_.notify_one(); |
749 | + } |
750 | + |
751 | +private: |
752 | + struct QueryData |
753 | + { |
754 | + std::string query; |
755 | + ReplyProxy::SPtr reply_proxy; |
756 | + }; |
757 | + std::list<QueryData> queries_; |
758 | + std::mutex mutex_; |
759 | + std::condition_variable condvar_; |
760 | +}; |
761 | + |
762 | +extern "C" |
763 | +{ |
764 | + |
765 | + EXPORT |
766 | + unity::api::scopes::ScopeBase* |
767 | + // cppcheck-suppress unusedFunction |
768 | + UNITY_API_SCOPE_CREATE_FUNCTION() |
769 | + { |
770 | + return new MyScope; |
771 | + } |
772 | + |
773 | + EXPORT |
774 | + void |
775 | + // cppcheck-suppress unusedFunction |
776 | + UNITY_API_SCOPE_DESTROY_FUNCTION(unity::api::scopes::ScopeBase* scope_base) |
777 | + { |
778 | + delete scope_base; |
779 | + } |
780 | + |
781 | +} |
782 | |
783 | === added file 'demo/scoperunner-A.cpp' |
784 | --- demo/scoperunner-A.cpp 1970-01-01 00:00:00 +0000 |
785 | +++ demo/scoperunner-A.cpp 2013-08-05 06:40:36 +0000 |
786 | @@ -0,0 +1,57 @@ |
787 | +/* |
788 | + * Copyright (C) 2013 Canonical Ltd |
789 | + * |
790 | + * This program is free software: you can redistribute it and/or modify |
791 | + * it under the terms of the GNU General Public License version 3 as |
792 | + * published by the Free Software Foundation. |
793 | + * |
794 | + * This program is distributed in the hope that it will be useful, |
795 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
796 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
797 | + * GNU General Public License for more details. |
798 | + * |
799 | + * You should have received a copy of the GNU General Public License |
800 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
801 | + * |
802 | + * Authored by: Michi Henning <michi.henning@canonical.com> |
803 | + */ |
804 | + |
805 | +#include <unity/api/scopes/internal/RuntimeImpl.h> |
806 | +#include <unity/api/scopes/internal/ScopeLoader.h> |
807 | +#include <unity/api/scopes/internal/ScopeObject.h> |
808 | +#include <unity/UnityExceptions.h> |
809 | + |
810 | +#include <iostream> |
811 | + |
812 | +using namespace std; |
813 | +using namespace unity::api::scopes; |
814 | +using namespace unity::api::scopes::internal; |
815 | + |
816 | +int |
817 | +main(int, char**) |
818 | +{ |
819 | + // TODO: the hard-wired strings here need to be read from config. |
820 | + |
821 | + string scope_name = string("scope-A"); |
822 | + |
823 | + try |
824 | + { |
825 | + RuntimeImpl::UPtr rt = RuntimeImpl::create(scope_name); |
826 | + MiddlewareBase::SPtr mw = rt->factory()->create(scope_name, "Ice", "Ice.Config"); |
827 | + // TODO: Need to call start on mw? |
828 | + ScopeLoader::SPtr loader = ScopeLoader::load(scope_name, "lib" + scope_name + ".so", rt->registry()); |
829 | + loader->start(); |
830 | + ScopeObject::SPtr scope(new ScopeObject(loader->scope_base())); |
831 | + mw->add_scope_object(scope_name, scope); |
832 | + // Call run here? |
833 | + mw->wait_for_shutdown(); |
834 | + } |
835 | + |
836 | + catch (unity::Exception const& e) |
837 | + { |
838 | + cerr << e.to_string() << endl; |
839 | + return 1; |
840 | + } |
841 | + |
842 | + return 0; |
843 | +} |
844 | |
845 | === added file 'demo/scoperunner-BC.cpp' |
846 | --- demo/scoperunner-BC.cpp 1970-01-01 00:00:00 +0000 |
847 | +++ demo/scoperunner-BC.cpp 2013-08-05 06:40:36 +0000 |
848 | @@ -0,0 +1,65 @@ |
849 | +/* |
850 | + * Copyright (C) 2013 Canonical Ltd |
851 | + * |
852 | + * This program is free software: you can redistribute it and/or modify |
853 | + * it under the terms of the GNU General Public License version 3 as |
854 | + * published by the Free Software Foundation. |
855 | + * |
856 | + * This program is distributed in the hope that it will be useful, |
857 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
858 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
859 | + * GNU General Public License for more details. |
860 | + * |
861 | + * You should have received a copy of the GNU General Public License |
862 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
863 | + * |
864 | + * Authored by: Michi Henning <michi.henning@canonical.com> |
865 | + */ |
866 | + |
867 | +#include <unity/api/scopes/internal/RuntimeImpl.h> |
868 | +#include <unity/api/scopes/internal/ScopeLoader.h> |
869 | +#include <unity/api/scopes/internal/ScopeObject.h> |
870 | +#include <unity/UnityExceptions.h> |
871 | + |
872 | +#include <iostream> |
873 | + |
874 | +using namespace std; |
875 | +using namespace unity::api::scopes; |
876 | +using namespace unity::api::scopes::internal; |
877 | + |
878 | +int |
879 | +main(int, char**) |
880 | +{ |
881 | + // TODO: the hard-wired strings here need to be read from config. |
882 | + |
883 | + string scope_nameB = string("scope-B"); |
884 | + string scope_nameC = string("scope-C"); |
885 | + |
886 | + try |
887 | + { |
888 | + RuntimeImpl::UPtr rtB = RuntimeImpl::create(scope_nameB); |
889 | + MiddlewareBase::SPtr mwB = rtB->factory()->create(scope_nameB, "Ice", "Ice.Config"); |
890 | + ScopeLoader::SPtr loaderB = ScopeLoader::load(scope_nameB, "lib" + scope_nameB + ".so", rtB->registry()); |
891 | + loaderB->start(); |
892 | + ScopeObject::SPtr scopeB(new ScopeObject(loaderB->scope_base())); |
893 | + mwB->add_scope_object(scope_nameB, scopeB); |
894 | + |
895 | + RuntimeImpl::UPtr rtC = RuntimeImpl::create(scope_nameC); |
896 | + MiddlewareBase::SPtr mwC = rtC->factory()->create(scope_nameC, "Ice", "Ice.Config"); |
897 | + ScopeLoader::SPtr loaderC = ScopeLoader::load(scope_nameC, "lib" + scope_nameC + ".so", rtC->registry()); |
898 | + loaderC->start(); |
899 | + ScopeObject::SPtr scopeC(new ScopeObject(loaderC->scope_base())); |
900 | + mwC->add_scope_object(scope_nameC, scopeC); |
901 | + |
902 | + mwB->wait_for_shutdown(); |
903 | + mwC->wait_for_shutdown(); |
904 | + } |
905 | + |
906 | + catch (unity::Exception const& e) |
907 | + { |
908 | + cerr << e.to_string() << endl; |
909 | + return 1; |
910 | + } |
911 | + |
912 | + return 0; |
913 | +} |
914 | |
915 | === added file 'demo/scoperunner-D.cpp' |
916 | --- demo/scoperunner-D.cpp 1970-01-01 00:00:00 +0000 |
917 | +++ demo/scoperunner-D.cpp 2013-08-05 06:40:36 +0000 |
918 | @@ -0,0 +1,57 @@ |
919 | +/* |
920 | + * Copyright (C) 2013 Canonical Ltd |
921 | + * |
922 | + * This program is free software: you can redistribute it and/or modify |
923 | + * it under the terms of the GNU General Public License version 3 as |
924 | + * published by the Free Software Foundation. |
925 | + * |
926 | + * This program is distributed in the hope that it will be useful, |
927 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
928 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
929 | + * GNU General Public License for more details. |
930 | + * |
931 | + * You should have received a copy of the GNU General Public License |
932 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
933 | + * |
934 | + * Authored by: Michi Henning <michi.henning@canonical.com> |
935 | + */ |
936 | + |
937 | +#include <unity/api/scopes/internal/RuntimeImpl.h> |
938 | +#include <unity/api/scopes/internal/ScopeLoader.h> |
939 | +#include <unity/api/scopes/internal/ScopeObject.h> |
940 | +#include <unity/UnityExceptions.h> |
941 | + |
942 | +#include <iostream> |
943 | + |
944 | +using namespace std; |
945 | +using namespace unity::api::scopes; |
946 | +using namespace unity::api::scopes::internal; |
947 | + |
948 | +int |
949 | +main(int, char**) |
950 | +{ |
951 | + // TODO: the hard-wired strings here need to be read from config. |
952 | + |
953 | + string scope_name = string("scope-D"); |
954 | + |
955 | + try |
956 | + { |
957 | + RuntimeImpl::UPtr rt = RuntimeImpl::create(scope_name); |
958 | + MiddlewareBase::SPtr mw = rt->factory()->create(scope_name, "Ice", "Ice.Config"); |
959 | + // TODO: Need to call start on mw? |
960 | + ScopeLoader::SPtr loader = ScopeLoader::load(scope_name, "lib" + scope_name + ".so", rt->registry()); |
961 | + loader->start(); |
962 | + ScopeObject::SPtr scope(new ScopeObject(loader->scope_base())); |
963 | + mw->add_scope_object(scope_name, scope); |
964 | + // Call run here? |
965 | + mw->wait_for_shutdown(); |
966 | + } |
967 | + |
968 | + catch (unity::Exception const& e) |
969 | + { |
970 | + cerr << e.to_string() << endl; |
971 | + return 1; |
972 | + } |
973 | + |
974 | + return 0; |
975 | +} |
976 | |
977 | === modified file 'include/unity/CMakeLists.txt' |
978 | --- include/unity/CMakeLists.txt 2013-05-29 04:57:50 +0000 |
979 | +++ include/unity/CMakeLists.txt 2013-08-05 06:40:36 +0000 |
980 | @@ -1,8 +1,7 @@ |
981 | add_subdirectory(api) |
982 | |
983 | file(GLOB headers "${CMAKE_CURRENT_SOURCE_DIR}/*.h") |
984 | -file(GLOB internal_headers "${CMAKE_CURRENT_SOURCE_DIR}/internal/*.h") |
985 | |
986 | install(FILES ${headers} DESTINATION ${HDR_INSTALL_DIR}/unity) |
987 | |
988 | -set(UNITY_SCOPES_LIB_HDRS ${UNITY_SCOPES_LIB_HDRS} ${headers} ${internal_headers} PARENT_SCOPE) |
989 | +set(UNITY_SCOPES_LIB_HDRS ${UNITY_SCOPES_LIB_HDRS} ${headers} PARENT_SCOPE) |
990 | |
991 | === modified file 'include/unity/api/CMakeLists.txt' |
992 | --- include/unity/api/CMakeLists.txt 2013-05-29 04:57:50 +0000 |
993 | +++ include/unity/api/CMakeLists.txt 2013-08-05 06:40:36 +0000 |
994 | @@ -1,8 +1,7 @@ |
995 | add_subdirectory(scopes) |
996 | |
997 | file(GLOB headers "${CMAKE_CURRENT_SOURCE_DIR}/*.h") |
998 | -file(GLOB internal_headers "${CMAKE_CURRENT_SOURCE_DIR}/internal/*.h") |
999 | |
1000 | -set(UNITY_SCOPES_LIB_HDRS ${UNITY_SCOPES_LIB_HDRS} ${headers} ${internal_headers} PARENT_SCOPE) |
1001 | +set(UNITY_SCOPES_LIB_HDRS ${UNITY_SCOPES_LIB_HDRS} ${headers} PARENT_SCOPE) |
1002 | |
1003 | install(FILES ${headers} DESTINATION ${HDR_INSTALL_DIR}/unity/api/scopes) |
1004 | |
1005 | === added directory 'include/unity/api/internal' |
1006 | === removed directory 'include/unity/api/internal' |
1007 | === modified file 'include/unity/api/scopes/CMakeLists.txt' |
1008 | --- include/unity/api/scopes/CMakeLists.txt 2013-05-29 04:57:50 +0000 |
1009 | +++ include/unity/api/scopes/CMakeLists.txt 2013-08-05 06:40:36 +0000 |
1010 | @@ -1,5 +1,6 @@ |
1011 | +add_subdirectory(internal) |
1012 | + |
1013 | file(GLOB headers "${CMAKE_CURRENT_SOURCE_DIR}/*.h") |
1014 | -file(GLOB internal_headers "${CMAKE_CURRENT_SOURCE_DIR}/internal/*.h") |
1015 | |
1016 | # |
1017 | # Generated headers |
1018 | @@ -9,4 +10,4 @@ |
1019 | |
1020 | install(FILES ${headers} DESTINATION ${HDR_INSTALL_DIR}/unity/scopes) |
1021 | |
1022 | -set(UNITY_SCOPES_LIB_HDRS ${UNITY_SCOPES_LIB_HDRS} ${headers} ${internal_headers} PARENT_SCOPE) |
1023 | +set(UNITY_SCOPES_LIB_HDRS ${UNITY_SCOPES_LIB_HDRS} ${headers} PARENT_SCOPE) |
1024 | |
1025 | === added file 'include/unity/api/scopes/ObjectProxy.h' |
1026 | --- include/unity/api/scopes/ObjectProxy.h 1970-01-01 00:00:00 +0000 |
1027 | +++ include/unity/api/scopes/ObjectProxy.h 2013-08-05 06:40:36 +0000 |
1028 | @@ -0,0 +1,57 @@ |
1029 | +/* |
1030 | + * Copyright (C) 2013 Canonical Ltd |
1031 | + * |
1032 | + * This program is free software: you can redistribute it and/or modify |
1033 | + * it under the terms of the GNU General Public License version 3 as |
1034 | + * published by the Free Software Foundation. |
1035 | + * |
1036 | + * This program is distributed in the hope that it will be useful, |
1037 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1038 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1039 | + * GNU General Public License for more details. |
1040 | + * |
1041 | + * You should have received a copy of the GNU General Public License |
1042 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1043 | + * |
1044 | + * Authored by: Michi Henning <michi.henning@canonical.com> |
1045 | + */ |
1046 | + |
1047 | +#ifndef UNITY_API_SCOPES_OBJECTPROXY_H |
1048 | +#define UNITY_API_SCOPES_OBJECTPROXY_H |
1049 | + |
1050 | +#include <unity/SymbolExport.h> |
1051 | +#include <unity/util/DefinesPtrs.h> |
1052 | + |
1053 | +namespace unity |
1054 | +{ |
1055 | + |
1056 | +namespace api |
1057 | +{ |
1058 | + |
1059 | +namespace scopes |
1060 | +{ |
1061 | + |
1062 | +/** |
1063 | +\brief Common base class for all proxies. |
1064 | +*/ |
1065 | + |
1066 | +class UNITY_API ObjectProxy |
1067 | +{ |
1068 | +public: |
1069 | + /// @cond |
1070 | + UNITY_DEFINES_PTRS(ObjectProxy); |
1071 | + /// @endcond |
1072 | + |
1073 | + virtual ~ObjectProxy() noexcept; |
1074 | + |
1075 | +protected: |
1076 | + ObjectProxy(); |
1077 | +}; |
1078 | + |
1079 | +} // namespace scopes |
1080 | + |
1081 | +} // namespace api |
1082 | + |
1083 | +} // namespace unity |
1084 | + |
1085 | +#endif |
1086 | |
1087 | === added file 'include/unity/api/scopes/RegistryProxy.h' |
1088 | --- include/unity/api/scopes/RegistryProxy.h 1970-01-01 00:00:00 +0000 |
1089 | +++ include/unity/api/scopes/RegistryProxy.h 2013-08-05 06:40:36 +0000 |
1090 | @@ -0,0 +1,83 @@ |
1091 | +/* |
1092 | + * Copyright (C) 2013 Canonical Ltd |
1093 | + * |
1094 | + * This program is free software: you can redistribute it and/or modify |
1095 | + * it under the terms of the Lesser GNU General Public License version 3 as |
1096 | + * published by the Free Software Foundation. |
1097 | + * |
1098 | + * This program is distributed in the hope that it will be useful, |
1099 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1100 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1101 | + * Lesser GNU General Public License for more details. |
1102 | + * |
1103 | + * You should have received a copy of the Lesser GNU General Public License |
1104 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1105 | + * |
1106 | + * Authored by: Michi Henning <michi.henning@canonical.com> |
1107 | + */ |
1108 | + |
1109 | +#ifndef UNITY_API_SCOPES_REGISTRYPROXY_H |
1110 | +#define UNITY_API_SCOPES_REGISTRYPROXY_H |
1111 | + |
1112 | +#include <unity/api/scopes/ScopeProxy.h> |
1113 | + |
1114 | +#include <map> |
1115 | + |
1116 | +namespace unity |
1117 | +{ |
1118 | + |
1119 | +namespace api |
1120 | +{ |
1121 | + |
1122 | +namespace scopes |
1123 | +{ |
1124 | + |
1125 | +namespace internal |
1126 | +{ |
1127 | +class RegistryProxyImpl; |
1128 | +} |
1129 | + |
1130 | +/** |
1131 | +\brief Map for scope name and proxy pairs. |
1132 | +*/ |
1133 | +typedef std::map<std::string, ScopeProxy::SPtr> ScopeMap; |
1134 | + |
1135 | +/** |
1136 | +\brief RegistryProxy provides access to the available scopes. |
1137 | +You can obtain a proxy to the registry by calling Runtime::registry(). |
1138 | +*/ |
1139 | + |
1140 | +class UNITY_API RegistryProxy : public ObjectProxy |
1141 | +{ |
1142 | +public: |
1143 | + /// @cond |
1144 | + UNITY_DEFINES_PTRS(RegistryProxy); |
1145 | + |
1146 | + virtual ~RegistryProxy() noexcept; |
1147 | + /// @endcond |
1148 | + |
1149 | + /** |
1150 | + \brief Returns a ScopeProxy for the scope with the given name. |
1151 | + @return If no scope with the given name exists, the returned `shared_ptr` stores a `nullptr`. |
1152 | + */ |
1153 | + ScopeProxy::SPtr find(std::string const& scope_name) const; |
1154 | + |
1155 | + /** |
1156 | + \brief Returns a map containing the name/proxy pairs for all available scopes. |
1157 | + */ |
1158 | + ScopeMap list() const; |
1159 | + |
1160 | +private: |
1161 | + RegistryProxy(internal::RegistryProxyImpl* impl); // Only instantiable by RegistryProxyImpl |
1162 | + friend class internal::RegistryProxyImpl; |
1163 | + |
1164 | + std::shared_ptr<internal::RegistryProxyImpl> p; |
1165 | +}; |
1166 | + |
1167 | +} // namespace scopes |
1168 | + |
1169 | +} // namespace api |
1170 | + |
1171 | +} // namespace unity |
1172 | + |
1173 | +#endif |
1174 | |
1175 | === added file 'include/unity/api/scopes/ReplyBase.h' |
1176 | --- include/unity/api/scopes/ReplyBase.h 1970-01-01 00:00:00 +0000 |
1177 | +++ include/unity/api/scopes/ReplyBase.h 2013-08-05 06:40:36 +0000 |
1178 | @@ -0,0 +1,76 @@ |
1179 | +/* |
1180 | + * Copyright (C) 2013 Canonical Ltd |
1181 | + * |
1182 | + * This program is free software: you can redistribute it and/or modify |
1183 | + * it under the terms of the Lesser GNU General Public License version 3 as |
1184 | + * published by the Free Software Foundation. |
1185 | + * |
1186 | + * This program is distributed in the hope that it will be useful, |
1187 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1188 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1189 | + * Lesser GNU General Public License for more details. |
1190 | + * |
1191 | + * You should have received a copy of the Lesser GNU General Public License |
1192 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1193 | + * |
1194 | + * Authored by: Michi Henning <michi.henning@canonical.com> |
1195 | + */ |
1196 | + |
1197 | +#ifndef UNITY_API_SCOPES_REPLYBASE_H |
1198 | +#define UNITY_API_SCOPES_REPLYBASE_H |
1199 | + |
1200 | +#include <unity/SymbolExport.h> |
1201 | +#include <unity/util/DefinesPtrs.h> |
1202 | +#include <unity/util/NonCopyable.h> |
1203 | + |
1204 | +#include <string> |
1205 | + |
1206 | +namespace unity |
1207 | +{ |
1208 | + |
1209 | +namespace api |
1210 | +{ |
1211 | + |
1212 | +namespace scopes |
1213 | +{ |
1214 | + |
1215 | +/** |
1216 | +\brief Abstract base class to receive the results of a query. |
1217 | +The scope application code must instantiate a class derived from ReplyBase and pass that instance as |
1218 | +a parameter to the ScopeProxy::query() method. Once a query is sent, the scopes run time repeatedly |
1219 | +invokes the send() method, once for each result returned by the query. Once a query is complete, |
1220 | +the finished() method is called once, to inform the caller that the query is complete. |
1221 | +*/ |
1222 | + |
1223 | +class UNITY_API ReplyBase : private util::NonCopyable |
1224 | +{ |
1225 | +public: |
1226 | + /// @cond |
1227 | + UNITY_DEFINES_PTRS(ReplyBase); |
1228 | + |
1229 | + virtual ~ReplyBase() noexcept; |
1230 | + /// @endcond |
1231 | + |
1232 | + /** |
1233 | + \brief Called once by the scopes run time for each result that is returned by a query(). |
1234 | + */ |
1235 | + virtual void send(std::string const& result) = 0; |
1236 | + |
1237 | + /** |
1238 | + \brief Called once by the scopes run time after the final result for a query() was sent. |
1239 | + */ |
1240 | + virtual void finished() = 0; |
1241 | + |
1242 | +protected: |
1243 | + /// @cond |
1244 | + ReplyBase(); |
1245 | + /// @endcond |
1246 | +}; |
1247 | + |
1248 | +} // namespace scopes |
1249 | + |
1250 | +} // namespace api |
1251 | + |
1252 | +} // namespace unity |
1253 | + |
1254 | +#endif |
1255 | |
1256 | === added file 'include/unity/api/scopes/ReplyProxy.h' |
1257 | --- include/unity/api/scopes/ReplyProxy.h 1970-01-01 00:00:00 +0000 |
1258 | +++ include/unity/api/scopes/ReplyProxy.h 2013-08-05 06:40:36 +0000 |
1259 | @@ -0,0 +1,86 @@ |
1260 | +/* |
1261 | + * Copyright (C) 2013 Canonical Ltd |
1262 | + * |
1263 | + * This program is free software: you can redistribute it and/or modify |
1264 | + * it under the terms of the Lesser GNU General Public License version 3 as |
1265 | + * published by the Free Software Foundation. |
1266 | + * |
1267 | + * This program is distributed in the hope that it will be useful, |
1268 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1269 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1270 | + * Lesser GNU General Public License for more details. |
1271 | + * |
1272 | + * You should have received a copy of the Lesser GNU General Public License |
1273 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1274 | + * |
1275 | + * Authored by: Michi Henning <michi.henning@canonical.com> |
1276 | + */ |
1277 | + |
1278 | +#ifndef UNITY_API_SCOPES_REPLYPROXY_H |
1279 | +#define UNITY_API_SCOPES_REPLYPROXY_H |
1280 | + |
1281 | +#include <unity/api/scopes/ObjectProxy.h> |
1282 | + |
1283 | +namespace unity |
1284 | +{ |
1285 | + |
1286 | +namespace api |
1287 | +{ |
1288 | + |
1289 | +namespace scopes |
1290 | +{ |
1291 | + |
1292 | +namespace internal |
1293 | +{ |
1294 | +class ReplyProxyImpl; |
1295 | +} |
1296 | + |
1297 | +/** |
1298 | +\brief ReplyProxy allows the results of a query to be sent to the source of the query. |
1299 | +*/ |
1300 | + |
1301 | +class UNITY_API ReplyProxy : public ObjectProxy |
1302 | +{ |
1303 | +public: |
1304 | + /// @cond |
1305 | + UNITY_DEFINES_PTRS(ReplyProxy); |
1306 | + /// @endcond |
1307 | + |
1308 | + /** |
1309 | + \brief Sends a single result to the source of a query. |
1310 | + Any calls to send() after finished() was called are ignored. |
1311 | + */ |
1312 | + virtual void send(std::string const& result); |
1313 | + |
1314 | + /** |
1315 | + \brief Informs the source of a query that the query results are complete. |
1316 | + Calling finished() informs the source of a query that the final result for the query |
1317 | + was sent, that is, that the query is complete. |
1318 | + The scope application code is responsible for calling finished() once it has sent the |
1319 | + final result for a query. |
1320 | + Multiple calls to finished() are ignored. |
1321 | + The destructor implicitly calls finished() if a ReplyProxy goes out of scope without |
1322 | + a prior call to finished(). |
1323 | + */ |
1324 | + virtual void finished(); |
1325 | + |
1326 | + /** |
1327 | + \brief Destroys a ReplyProxy. |
1328 | + If a ReplyProxy goes out of scope without a prior call to finished(), the destructor implicitly calls finished(). |
1329 | + */ |
1330 | + virtual ~ReplyProxy() noexcept; |
1331 | + |
1332 | +private: |
1333 | + ReplyProxy(internal::ReplyProxyImpl* impl); // Only instantiable by ReplyProxyImpl |
1334 | + friend class internal::ReplyProxyImpl; |
1335 | + |
1336 | + std::shared_ptr<internal::ReplyProxyImpl> p; |
1337 | +}; |
1338 | + |
1339 | +} // namespace scopes |
1340 | + |
1341 | +} // namespace api |
1342 | + |
1343 | +} // namespace unity |
1344 | + |
1345 | +#endif |
1346 | |
1347 | === added file 'include/unity/api/scopes/Runtime.h' |
1348 | --- include/unity/api/scopes/Runtime.h 1970-01-01 00:00:00 +0000 |
1349 | +++ include/unity/api/scopes/Runtime.h 2013-08-05 06:40:36 +0000 |
1350 | @@ -0,0 +1,100 @@ |
1351 | +/* |
1352 | + * Copyright (C) 2013 Canonical Ltd |
1353 | + * |
1354 | + * This program is free software: you can redistribute it and/or modify |
1355 | + * it under the terms of the Lesser GNU General Public License version 3 as |
1356 | + * published by the Free Software Foundation. |
1357 | + * |
1358 | + * This program is distributed in the hope that it will be useful, |
1359 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1360 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1361 | + * Lesser GNU General Public License for more details. |
1362 | + * |
1363 | + * You should have received a copy of the Lesser GNU General Public License |
1364 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1365 | + * |
1366 | + * Authored by: Michi Henning <michi.henning@canonical.com> |
1367 | + */ |
1368 | + |
1369 | +#ifndef UNITY_API_SCOPES_RUNTIME_H |
1370 | +#define UNITY_API_SCOPES_RUNTIME_H |
1371 | + |
1372 | +#include <unity/api/scopes/RegistryProxy.h> |
1373 | + |
1374 | +namespace unity |
1375 | +{ |
1376 | + |
1377 | +namespace api |
1378 | +{ |
1379 | + |
1380 | +namespace scopes |
1381 | +{ |
1382 | + |
1383 | +namespace internal |
1384 | +{ |
1385 | +class RuntimeImpl; |
1386 | +} |
1387 | + |
1388 | +/** |
1389 | +\brief The main object to access the scopes run time. |
1390 | +All interactions with the scopes run time require a Runtime object to be instantiated first. The Runtime instance |
1391 | +controls the overall life cycle; once a Runtime instance goes out of scope, the application must not make further |
1392 | +calls on any instance obtained via the destroyed Runtime. |
1393 | + |
1394 | +The application must instantiate a Runtime object only after `main()` is entered, and it must destroy the instance |
1395 | +before leaving `main()`; failure to do so result in undefined behavior. |
1396 | +*/ |
1397 | + |
1398 | +class UNITY_API Runtime : private util::NonCopyable |
1399 | +{ |
1400 | +public: |
1401 | + /// @cond |
1402 | + UNITY_DEFINES_PTRS(Runtime); |
1403 | + /// @endcond |
1404 | + |
1405 | + /** |
1406 | + \brief The default configuration file (relative to the current directory) if none is passed to create(). |
1407 | + */ |
1408 | + static constexpr char const* DFLT_CONFIGFILE = "Scopes.ini"; |
1409 | + |
1410 | + /** |
1411 | + \brief Instantiates the scopes run time for the scope with the given name and (optional) configuration file. |
1412 | + The life time of the run time is under control of the caller. Letting the returned `unique_ptr` go out |
1413 | + of scope shuts down the run time. |
1414 | + */ |
1415 | + static UPtr create(std::string const& scope_name, std::string const& configfile = DFLT_CONFIGFILE); |
1416 | + |
1417 | + /** |
1418 | + \brief Shuts down the run time, reclaiming all associated resources. |
1419 | + Calling destroy() is optional; the destructor implicitly calls destroy() if it was not called explicitly. |
1420 | + However, no exceptions are thrown by the destructor. If you want to log or handle any exceptions during |
1421 | + shutdown, call destroy() explicitly before letting the `unique_ptr` returned by create() go out of scope. |
1422 | + */ |
1423 | + void destroy(); |
1424 | + |
1425 | + /** |
1426 | + \brief Returns a proxy to the Registry object. |
1427 | + The returned proxy allows application code to interact with the registry, which provides access to the available |
1428 | + scopes. |
1429 | + */ |
1430 | + RegistryProxy::SPtr registry() const; |
1431 | + |
1432 | + /** |
1433 | + \brief Destroys a Runtime instance. |
1434 | + The destructor implicitly calls destroy() if the application code does not explicitly destroy the instance. |
1435 | + */ |
1436 | + ~Runtime() noexcept; |
1437 | + |
1438 | +private: |
1439 | + Runtime(std::string const& scope_name, std::string const& configfile); // Instantiation only via create() |
1440 | + |
1441 | + std::unique_ptr<internal::RuntimeImpl> p; |
1442 | +}; |
1443 | + |
1444 | +} // namespace scopes |
1445 | + |
1446 | +} // namespace api |
1447 | + |
1448 | +} // namespace unity |
1449 | + |
1450 | +#endif |
1451 | |
1452 | === modified file 'include/unity/api/scopes/ScopeBase.h' |
1453 | --- include/unity/api/scopes/ScopeBase.h 2013-07-04 00:39:02 +0000 |
1454 | +++ include/unity/api/scopes/ScopeBase.h 2013-08-05 06:40:36 +0000 |
1455 | @@ -21,9 +21,12 @@ |
1456 | |
1457 | #include <unity/SymbolExport.h> |
1458 | #include <unity/util/NonCopyable.h> |
1459 | +#include <unity/api/scopes/RegistryProxy.h> |
1460 | +#include <unity/api/scopes/ReplyProxy.h> |
1461 | #include <unity/api/scopes/Version.h> |
1462 | |
1463 | #include <memory> |
1464 | +#include <iostream> // TODO:REMOVE THIS |
1465 | |
1466 | /** |
1467 | \brief Expands to the identifier of the scope create function. @hideinitializer |
1468 | @@ -81,8 +84,9 @@ |
1469 | MyScope(); |
1470 | virtual ~MyScope(); |
1471 | |
1472 | - virtual void start(); |
1473 | + virtual int start(); |
1474 | virtual void stop(); |
1475 | + virtual void run(); |
1476 | }; |
1477 | ~~~ |
1478 | |
1479 | @@ -115,22 +119,33 @@ |
1480 | |
1481 | After the Unity run time has obtained a pointer to the class instance from the create function, it calls start(), |
1482 | which allows the scope to intialize itself. Once start() returns, incoming query requests are dispatched to the scope. |
1483 | -When the scope should complete its activities, the run time calls stop(). The calls to start() and |
1484 | -stop() are made by the same thread. |
1485 | +When the scope should complete its activities, the run time calls stop(). The calls to the create function, start(), |
1486 | +stop(), and the destroy function) are made by the same thread. The call to run() is made by a _different_ thread. |
1487 | */ |
1488 | |
1489 | class UNITY_API ScopeBase : private util::NonCopyable |
1490 | { |
1491 | public: |
1492 | /// @cond |
1493 | - virtual ~ScopeBase() {} |
1494 | + virtual ~ScopeBase(); |
1495 | /// @endcond |
1496 | |
1497 | /** |
1498 | + \brief This value must be returned from the start() method. |
1499 | + */ |
1500 | + static constexpr int VERSION = UNITY_SCOPES_VERSION_MAJOR; |
1501 | + |
1502 | + /** |
1503 | \brief Called by the Unity run time after initialize() completes. |
1504 | - If start() throws an exception, stop() will _not_ be called (but finalize() _will_ be called). |
1505 | + If start() throws an exception, stop() will _not_ be called. |
1506 | + |
1507 | + The call to start() is made by the same thread that calls the create function. |
1508 | + |
1509 | + \return Any return value other than SCOPES_MAJOR_VERSION will cause the Unity run time |
1510 | + to refuse to load the scope. The return value is used to ensure that the shared library |
1511 | + containing the scope is ABI compatible with the Unity scopes run time. |
1512 | */ |
1513 | - virtual void start() = 0; |
1514 | + virtual int start(RegistryProxy::SPtr const& registry) = 0; |
1515 | |
1516 | /** |
1517 | \brief Called by the Unity run time when the scope should shut down. |
1518 | @@ -138,20 +153,30 @@ |
1519 | deallocate any caches and close network connections. |
1520 | |
1521 | Exceptions from stop() are ignored. |
1522 | + |
1523 | + The call to stop() is made by the same thread that calls the create function and start(). |
1524 | */ |
1525 | virtual void stop() = 0; |
1526 | |
1527 | /** |
1528 | + \brief Called by the Unity run time to hand a thread of control to the scope. |
1529 | + run() passes a thread of control to the scope to do with as it sees fit, for example, to run an event loop. |
1530 | + |
1531 | + If run() throws an exception, stop() _will_ be called. |
1532 | + |
1533 | + The call to run() is made by a separate thread (not the thread that calls the create function and start()). |
1534 | + */ |
1535 | + virtual void run() = 0; |
1536 | + |
1537 | + /** |
1538 | \brief Called by the Unity run time when scope should process a query. |
1539 | - The passed functor can be used to push the results, either synchronously, while query() is still running, |
1540 | - or asynchronously, after query() has returned. |
1541 | - */ |
1542 | - virtual void query(std::string const& q, std::function<void(std::string const&)> callback) = 0; |
1543 | + TODO: complete documentation. |
1544 | |
1545 | - /** |
1546 | - \brief This method returns the version information for the scopes API that the scope was compiled with. |
1547 | + Calls to query() are made by an arbitrary thread. If the scope is configured to run single-threaded, all calls |
1548 | + to query() are made by the same thread. If the scope is configured to run multi-threaded, each call to query() |
1549 | + is made by an arbitrary thread, and several calls to query() may be made concurrently. |
1550 | */ |
1551 | - void compiled_version(int& v_major, int& v_minor, int& v_micro) noexcept; |
1552 | + virtual void query(std::string const& q, ReplyProxy::SPtr const& reply) = 0; |
1553 | |
1554 | /** |
1555 | \brief This method returns the version information for the scopes API that the scope was linked with. |
1556 | @@ -160,21 +185,10 @@ |
1557 | |
1558 | protected: |
1559 | /// @cond |
1560 | - ScopeBase() = default; |
1561 | + ScopeBase(); |
1562 | /// @endcond |
1563 | }; |
1564 | |
1565 | -// We inline this function so we are guaranteed to be returned the version of the scopes library that the derived |
1566 | -// class was compiled with. |
1567 | - |
1568 | -inline |
1569 | -void ScopeBase::compiled_version(int& v_major, int& v_minor, int& v_micro) noexcept |
1570 | -{ |
1571 | - v_major = UNITY_SCOPES_VERSION_MAJOR; |
1572 | - v_minor = UNITY_SCOPES_VERSION_MINOR; |
1573 | - v_micro = UNITY_SCOPES_VERSION_MICRO; |
1574 | -} |
1575 | - |
1576 | } // namespace scopes |
1577 | |
1578 | } // namespace api |
1579 | |
1580 | === modified file 'include/unity/api/scopes/ScopeExceptions.h' |
1581 | --- include/unity/api/scopes/ScopeExceptions.h 2013-06-18 09:02:02 +0000 |
1582 | +++ include/unity/api/scopes/ScopeExceptions.h 2013-08-05 06:40:36 +0000 |
1583 | @@ -64,6 +64,40 @@ |
1584 | virtual std::exception_ptr self() const override; |
1585 | }; |
1586 | |
1587 | +namespace internal |
1588 | +{ |
1589 | +class ConfigExceptionImpl; |
1590 | +} |
1591 | + |
1592 | +/** |
1593 | +\brief Exception to indicate that something went wrong with the contents of configuration files. |
1594 | +*/ |
1595 | + |
1596 | +class UNITY_API ConfigException : public unity::Exception |
1597 | +{ |
1598 | +public: |
1599 | + /** |
1600 | + \brief Constructs the exception. |
1601 | + \param reason Further details about the cause of the exception. |
1602 | + */ |
1603 | + explicit ConfigException(std::string const& reason); |
1604 | + //! @cond |
1605 | + ConfigException(ConfigException const&); |
1606 | + ConfigException& operator=(ConfigException const&); |
1607 | + virtual ~ConfigException() noexcept; |
1608 | + //! @endcond |
1609 | + |
1610 | + /** |
1611 | + \brief Returns the fully-qualified name of the exception. |
1612 | + */ |
1613 | + virtual char const* what() const noexcept override; |
1614 | + |
1615 | + /** |
1616 | + \brief Returns a <code>std::exception_ptr</code> to <code>this</code>. |
1617 | + */ |
1618 | + virtual std::exception_ptr self() const override; |
1619 | +}; |
1620 | + |
1621 | } // namespace scopes |
1622 | |
1623 | } // namespace api |
1624 | |
1625 | === added file 'include/unity/api/scopes/ScopeProxy.h' |
1626 | --- include/unity/api/scopes/ScopeProxy.h 1970-01-01 00:00:00 +0000 |
1627 | +++ include/unity/api/scopes/ScopeProxy.h 2013-08-05 06:40:36 +0000 |
1628 | @@ -0,0 +1,80 @@ |
1629 | +/* |
1630 | + * Copyright (C) 2013 Canonical Ltd |
1631 | + * |
1632 | + * This program is free software: you can redistribute it and/or modify |
1633 | + * it under the terms of the Lesser GNU General Public License version 3 as |
1634 | + * published by the Free Software Foundation. |
1635 | + * |
1636 | + * This program is distributed in the hope that it will be useful, |
1637 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1638 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1639 | + * Lesser GNU General Public License for more details. |
1640 | + * |
1641 | + * You should have received a copy of the Lesser GNU General Public License |
1642 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1643 | + * |
1644 | + * Authored by: Michi Henning <michi.henning@canonical.com> |
1645 | + */ |
1646 | + |
1647 | +#ifndef UNITY_API_SCOPES_SCOPEPROXY_H |
1648 | +#define UNITY_API_SCOPES_SCOPEPROXY_H |
1649 | + |
1650 | +#include <unity/api/scopes/ObjectProxy.h> |
1651 | +#include <unity/api/scopes/ReplyBase.h> |
1652 | + |
1653 | +#include <string> |
1654 | + |
1655 | +namespace unity |
1656 | +{ |
1657 | + |
1658 | +namespace api |
1659 | +{ |
1660 | + |
1661 | +namespace scopes |
1662 | +{ |
1663 | + |
1664 | +namespace internal |
1665 | +{ |
1666 | +class ScopeProxyImpl; |
1667 | +} |
1668 | + |
1669 | +/** |
1670 | +\brief Allows queries to be sent to a scope and results for the query to be retrieved. |
1671 | +*/ |
1672 | + |
1673 | +class UNITY_API ScopeProxy : public ObjectProxy |
1674 | +{ |
1675 | +public: |
1676 | + /// @cond |
1677 | + UNITY_DEFINES_PTRS(ScopeProxy); |
1678 | + /// @endcond |
1679 | + |
1680 | + /** |
1681 | + \brief Initiates a query. |
1682 | + The query() method expects an instance derived from ReplyBase, which it uses to return |
1683 | + the results for the query. query() is an asynchronous method, that is, it returns immediately; |
1684 | + results for the query typically will arrive only after the query() method completes (but may |
1685 | + also arrive while the query() method is still running. |
1686 | + */ |
1687 | + void query(std::string const& q, ReplyBase::SPtr const& reply); |
1688 | + |
1689 | + /** |
1690 | + \brief Destroys a ScopeProxy. |
1691 | + Destroying a ScopeProxy has no effect on any query that might still be in progress. |
1692 | + */ |
1693 | + virtual ~ScopeProxy() noexcept; |
1694 | + |
1695 | +private: |
1696 | + ScopeProxy(internal::ScopeProxyImpl* impl); // Only instantiable by ScopeProxyImpl |
1697 | + friend class internal::ScopeProxyImpl; |
1698 | + |
1699 | + std::shared_ptr<internal::ScopeProxyImpl> p; |
1700 | +}; |
1701 | + |
1702 | +} // namespace scopes |
1703 | + |
1704 | +} // namespace api |
1705 | + |
1706 | +} // namespace unity |
1707 | + |
1708 | +#endif |
1709 | |
1710 | === modified file 'include/unity/api/scopes/Version.h.in' |
1711 | --- include/unity/api/scopes/Version.h.in 2013-06-27 08:38:02 +0000 |
1712 | +++ include/unity/api/scopes/Version.h.in 2013-08-05 06:40:36 +0000 |
1713 | @@ -25,11 +25,24 @@ |
1714 | #ifndef UNITY_API_SCOPES_VERSION_H |
1715 | #define UNITY_API_SCOPES_VERSION_H |
1716 | |
1717 | -#define UNITY_SCOPES_VERSION_MAJOR @UNITY_SCOPES_MAJOR@ |
1718 | -#define UNITY_SCOPES_VERSION_MINOR @UNITY_SCOPES_MINOR@ |
1719 | -#define UNITY_SCOPES_VERSION_MICRO @UNITY_SCOPES_MICRO@ |
1720 | - |
1721 | -#define UNITY_SCOPES_VERSION_STRING "@UNITY_SCOPES_VERSION@" |
1722 | +#ifndef UNITY_SCOPES_VERSION_MAJOR |
1723 | +# define UNITY_SCOPES_VERSION_MAJOR @UNITY_SCOPES_MAJOR@ |
1724 | +#endif |
1725 | + |
1726 | +#ifndef UNITY_SCOPES_VERSION_MINOR |
1727 | +# define UNITY_SCOPES_VERSION_MINOR @UNITY_SCOPES_MINOR@ |
1728 | +#endif |
1729 | + |
1730 | +#ifndef UNITY_SCOPES_VERSION_MICRO |
1731 | +# define UNITY_SCOPES_VERSION_MICRO @UNITY_SCOPES_MICRO@ |
1732 | +#endif |
1733 | + |
1734 | +#define UNITY_SCOPES_VERSION_STR(s) #s |
1735 | +#define UNITY_SCOPES_VERSION_XSTR(s) UNITY_SCOPES_VERSION_STR(s) |
1736 | + |
1737 | +#define UNITY_SCOPES_VERSION_STRING UNITY_SCOPES_VERSION_XSTR(UNITY_SCOPES_VERSION_MAJOR) "." \ |
1738 | + UNITY_SCOPES_VERSION_XSTR(UNITY_SCOPES_VERSION_MINOR) "." \ |
1739 | + UNITY_SCOPES_VERSION_XSTR(UNITY_SCOPES_VERSION_MICRO) |
1740 | |
1741 | /** |
1742 | \brief Top-level namespace for all things Unity-related. |
1743 | @@ -54,12 +67,14 @@ |
1744 | Version information is represented as |
1745 | <i><<code>major</code>></i>.<i><<code>minor</code>></i>.<i><<code>micro</code>></i>. |
1746 | |
1747 | -Releases that differ in the major or minor version number are binary incompatible. |
1748 | +Releases that differ in the major version number are binary incompatible. |
1749 | |
1750 | -Releases of the library that differ only in the micro version number are binary compatible with older releases, |
1751 | +Releases of the library that differ in the minor or micro version number are binary compatible with older releases, |
1752 | so client code does not need to be recompiled to use the newer library version. |
1753 | |
1754 | Changes in the micro version number indicate bug fixes. |
1755 | + |
1756 | +Changes in the minor version number indicate feature additions that are binary compatible. |
1757 | */ |
1758 | |
1759 | /** |
1760 | @@ -101,7 +116,7 @@ |
1761 | /// @cond |
1762 | UNITY_API |
1763 | /// @endcond |
1764 | -const char* str(); // Returns "major.minor.micro" |
1765 | +const char* version_string(); // Returns "major.minor.micro" |
1766 | |
1767 | /// }@ |
1768 | |
1769 | |
1770 | === added file 'include/unity/api/scopes/internal/AbstractObject.h' |
1771 | --- include/unity/api/scopes/internal/AbstractObject.h 1970-01-01 00:00:00 +0000 |
1772 | +++ include/unity/api/scopes/internal/AbstractObject.h 2013-08-05 06:40:36 +0000 |
1773 | @@ -0,0 +1,56 @@ |
1774 | +/* |
1775 | + * Copyright (C) 2013 Canonical Ltd |
1776 | + * |
1777 | + * This program is free software: you can redistribute it and/or modify |
1778 | + * it under the terms of the GNU General Public License version 3 as |
1779 | + * published by the Free Software Foundation. |
1780 | + * |
1781 | + * This program is distributed in the hope that it will be useful, |
1782 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1783 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1784 | + * GNU General Public License for more details. |
1785 | + * |
1786 | + * You should have received a copy of the GNU General Public License |
1787 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1788 | + * |
1789 | + * Authored by: Michi Henning <michi.henning@canonical.com> |
1790 | + */ |
1791 | + |
1792 | +#ifndef UNITY_API_SCOPES_INTERNAL_ABSTRACTOBJECT_H |
1793 | +#define UNITY_API_SCOPES_INTERNAL_ABSTRACTOBJECT_H |
1794 | + |
1795 | +#include <unity/util/DefinesPtrs.h> |
1796 | +#include <unity/util/NonCopyable.h> |
1797 | + |
1798 | +namespace unity |
1799 | +{ |
1800 | + |
1801 | +namespace api |
1802 | +{ |
1803 | + |
1804 | +namespace scopes |
1805 | +{ |
1806 | + |
1807 | +namespace internal |
1808 | +{ |
1809 | + |
1810 | +class AbstractObject : private util::NonCopyable |
1811 | +{ |
1812 | +public: |
1813 | + UNITY_DEFINES_PTRS(AbstractObject); |
1814 | + |
1815 | + virtual ~AbstractObject() noexcept; |
1816 | + |
1817 | +protected: |
1818 | + AbstractObject(); |
1819 | +}; |
1820 | + |
1821 | +} // namespace internal |
1822 | + |
1823 | +} // namespace scopes |
1824 | + |
1825 | +} // namespace api |
1826 | + |
1827 | +} // namespace unity |
1828 | + |
1829 | +#endif |
1830 | |
1831 | === added file 'include/unity/api/scopes/internal/CMakeLists.txt' |
1832 | --- include/unity/api/scopes/internal/CMakeLists.txt 1970-01-01 00:00:00 +0000 |
1833 | +++ include/unity/api/scopes/internal/CMakeLists.txt 2013-08-05 06:40:36 +0000 |
1834 | @@ -0,0 +1,5 @@ |
1835 | +add_subdirectory(ice_middleware) |
1836 | + |
1837 | +file(GLOB headers "${CMAKE_CURRENT_SOURCE_DIR}/*.h") |
1838 | + |
1839 | +set(UNITY_SCOPES_LIB_HDRS ${UNITY_SCOPES_LIB_HDRS} ${headers} PARENT_SCOPE) |
1840 | |
1841 | === added file 'include/unity/api/scopes/internal/ConfigBase.h' |
1842 | --- include/unity/api/scopes/internal/ConfigBase.h 1970-01-01 00:00:00 +0000 |
1843 | +++ include/unity/api/scopes/internal/ConfigBase.h 2013-08-05 06:40:36 +0000 |
1844 | @@ -0,0 +1,68 @@ |
1845 | +/* |
1846 | + * Copyright (C) 2013 Canonical Ltd |
1847 | + * |
1848 | + * This program is free software: you can redistribute it and/or modify |
1849 | + * it under the terms of the GNU General Public License version 3 as |
1850 | + * published by the Free Software Foundation. |
1851 | + * |
1852 | + * This program is distributed in the hope that it will be useful, |
1853 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1854 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1855 | + * GNU General Public License for more details. |
1856 | + * |
1857 | + * You should have received a copy of the GNU General Public License |
1858 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1859 | + * |
1860 | + * Authored by: Michi Henning <michi.henning@canonical.com> |
1861 | + */ |
1862 | + |
1863 | +#ifndef UNITY_API_SCOPES_INTERNAL_CONFIGBASE_H |
1864 | +#define UNITY_API_SCOPES_INTERNAL_CONFIGBASE_H |
1865 | + |
1866 | +#include <unity/util/IniParser.h> |
1867 | + |
1868 | +namespace unity |
1869 | +{ |
1870 | + |
1871 | +namespace util |
1872 | +{ |
1873 | +class IniParser; |
1874 | +} |
1875 | + |
1876 | +namespace api |
1877 | +{ |
1878 | + |
1879 | +namespace scopes |
1880 | +{ |
1881 | + |
1882 | +namespace internal |
1883 | +{ |
1884 | + |
1885 | +class ConfigBase |
1886 | +{ |
1887 | +public: |
1888 | + ConfigBase(std::string const& configfile); |
1889 | + virtual ~ConfigBase() noexcept; |
1890 | + |
1891 | + unity::util::IniParser::SPtr parser() const noexcept; |
1892 | + |
1893 | + virtual std::string get_string(std::string const& group, std::string const& key) const; |
1894 | + virtual std::string get_optional_string(std::string const& group, std::string const& key) const; |
1895 | + virtual std::string get_middleware(std::string const& group, std::string const& key) const; |
1896 | + |
1897 | + virtual void throw_ex(::std::string const& reason) const; |
1898 | + |
1899 | +private: |
1900 | + unity::util::IniParser::SPtr parser_; |
1901 | + std::string configfile_; |
1902 | +}; |
1903 | + |
1904 | +} // namespace internal |
1905 | + |
1906 | +} // namespace scopes |
1907 | + |
1908 | +} // namespace api |
1909 | + |
1910 | +} // namespace unity |
1911 | + |
1912 | +#endif |
1913 | |
1914 | === modified file 'include/unity/api/scopes/internal/DynamicLoader.h' |
1915 | --- include/unity/api/scopes/internal/DynamicLoader.h 2013-07-04 00:39:02 +0000 |
1916 | +++ include/unity/api/scopes/internal/DynamicLoader.h 2013-08-05 06:40:36 +0000 |
1917 | @@ -22,6 +22,8 @@ |
1918 | #include <unity/util/DefinesPtrs.h> |
1919 | #include <unity/util/NonCopyable.h> |
1920 | |
1921 | +#include <map> |
1922 | +#include <mutex> |
1923 | #include <string> |
1924 | |
1925 | namespace unity |
1926 | @@ -71,11 +73,19 @@ |
1927 | // int_func(5); |
1928 | // |
1929 | |
1930 | -class UNITY_API DynamicLoader : public unity::util::DefinesPtrs<DynamicLoader>, private util::NonCopyable |
1931 | +class UNITY_API DynamicLoader : private util::NonCopyable |
1932 | { |
1933 | public: |
1934 | - enum class Binding { lazy, now }; |
1935 | - enum class Unload { automatic, noclose }; |
1936 | + UNITY_DEFINES_PTRS(DynamicLoader); |
1937 | + |
1938 | + enum class Binding |
1939 | + { |
1940 | + lazy, now |
1941 | + }; |
1942 | + enum class Unload |
1943 | + { |
1944 | + automatic, noclose |
1945 | + }; |
1946 | |
1947 | static UPtr create(std::string const& path, Binding b = Binding::lazy, Unload ul = Unload::automatic); |
1948 | |
1949 | @@ -94,6 +104,10 @@ |
1950 | std::string path_; |
1951 | void* handle_; |
1952 | Unload unload_; |
1953 | + |
1954 | + typedef std::map<std::string, void*> LibraryHandles; |
1955 | + static LibraryHandles handles_; // Handles of libraries that will not be unloaded |
1956 | + static std::mutex mutex_; // Protects m_handle_map |
1957 | }; |
1958 | |
1959 | } // namespace internal |
1960 | |
1961 | === added file 'include/unity/api/scopes/internal/MWObject.h' |
1962 | --- include/unity/api/scopes/internal/MWObject.h 1970-01-01 00:00:00 +0000 |
1963 | +++ include/unity/api/scopes/internal/MWObject.h 2013-08-05 06:40:36 +0000 |
1964 | @@ -0,0 +1,65 @@ |
1965 | +/* |
1966 | + * Copyright (C) 2013 Canonical Ltd |
1967 | + * |
1968 | + * This program is free software: you can redistribute it and/or modify |
1969 | + * it under the terms of the GNU General Public License version 3 as |
1970 | + * published by the Free Software Foundation. |
1971 | + * |
1972 | + * This program is distributed in the hope that it will be useful, |
1973 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1974 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1975 | + * GNU General Public License for more details. |
1976 | + * |
1977 | + * You should have received a copy of the GNU General Public License |
1978 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1979 | + * |
1980 | + * Authored by: Michi Henning <michi.henning@canonical.com> |
1981 | + */ |
1982 | + |
1983 | +#ifndef UNITY_API_REPLYS_INTERNAL_MWOBJECT_H |
1984 | +#define UNITY_API_REPLYS_INTERNAL_MWOBJECT_H |
1985 | + |
1986 | +#include <unity/util/DefinesPtrs.h> |
1987 | + |
1988 | +namespace unity |
1989 | +{ |
1990 | + |
1991 | +namespace api |
1992 | +{ |
1993 | + |
1994 | +namespace scopes |
1995 | +{ |
1996 | + |
1997 | +namespace internal |
1998 | +{ |
1999 | + |
2000 | +class MiddlewareBase; |
2001 | + |
2002 | +// Base class for the MW<something>Object hierarchy. We store the pointer to the middleware here, |
2003 | +// which is needed to, for example, registry callback objects (such as a Reply object) with the middleware. |
2004 | + |
2005 | +class MWObject |
2006 | +{ |
2007 | +public: |
2008 | + UNITY_DEFINES_PTRS(MWObject); |
2009 | + |
2010 | + virtual ~MWObject() noexcept; |
2011 | + |
2012 | + MiddlewareBase* mw_base() const noexcept; |
2013 | + |
2014 | +protected: |
2015 | + MWObject(MiddlewareBase* mw_base); |
2016 | + |
2017 | +private: |
2018 | + MiddlewareBase* mw_base_; |
2019 | +}; |
2020 | + |
2021 | +} // namespace internal |
2022 | + |
2023 | +} // namespace scopes |
2024 | + |
2025 | +} // namespace api |
2026 | + |
2027 | +} // namespace unity |
2028 | + |
2029 | +#endif |
2030 | |
2031 | === added file 'include/unity/api/scopes/internal/MWObjectProxy.h' |
2032 | --- include/unity/api/scopes/internal/MWObjectProxy.h 1970-01-01 00:00:00 +0000 |
2033 | +++ include/unity/api/scopes/internal/MWObjectProxy.h 2013-08-05 06:40:36 +0000 |
2034 | @@ -0,0 +1,66 @@ |
2035 | +/* |
2036 | + * Copyright (C) 2013 Canonical Ltd |
2037 | + * |
2038 | + * This program is free software: you can redistribute it and/or modify |
2039 | + * it under the terms of the Lesser GNU General Public License version 3 as |
2040 | + * published by the Free Software Foundation. |
2041 | + * |
2042 | + * This program is distributed in the hope that it will be useful, |
2043 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
2044 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2045 | + * Lesser GNU General Public License for more details. |
2046 | + * |
2047 | + * You should have received a copy of the Lesser GNU General Public License |
2048 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
2049 | + * |
2050 | + * Authored by: Michi Henning <michi.henning@canonical.com> |
2051 | + */ |
2052 | + |
2053 | +#ifndef UNITY_API_SCOPES_INTERNAL_MWOBJECTPROXY_H |
2054 | +#define UNITY_API_SCOPES_INTERNAL_MWOBJECTPROXY_H |
2055 | + |
2056 | +#include <unity/util/DefinesPtrs.h> |
2057 | + |
2058 | +namespace unity |
2059 | +{ |
2060 | + |
2061 | +namespace api |
2062 | +{ |
2063 | + |
2064 | +namespace scopes |
2065 | +{ |
2066 | + |
2067 | +namespace internal |
2068 | +{ |
2069 | + |
2070 | +class MiddlewareBase; |
2071 | + |
2072 | +// Base class for all MW<something>Proxy types. Its job is to make the abstract middleware pointer |
2073 | +// available to all proxies, so it is possible to, for example, instantiate and add a new server-side |
2074 | +// object to the middleware (as is needed for callback objects). |
2075 | + |
2076 | +class MWObjectProxy |
2077 | +{ |
2078 | +public: |
2079 | + UNITY_DEFINES_PTRS(MWObjectProxy); |
2080 | + |
2081 | + MiddlewareBase* mw_base() const noexcept; |
2082 | + |
2083 | + virtual ~MWObjectProxy() noexcept; |
2084 | + |
2085 | +protected: |
2086 | + MWObjectProxy(MiddlewareBase* mw_base); |
2087 | + |
2088 | +private: |
2089 | + MiddlewareBase* mw_base_; |
2090 | +}; |
2091 | + |
2092 | +} // namespace internal |
2093 | + |
2094 | +} // namespace scopes |
2095 | + |
2096 | +} // namespace api |
2097 | + |
2098 | +} // namespace unity |
2099 | + |
2100 | +#endif |
2101 | |
2102 | === added file 'include/unity/api/scopes/internal/MWRegistryProxy.h' |
2103 | --- include/unity/api/scopes/internal/MWRegistryProxy.h 1970-01-01 00:00:00 +0000 |
2104 | +++ include/unity/api/scopes/internal/MWRegistryProxy.h 2013-08-05 06:40:36 +0000 |
2105 | @@ -0,0 +1,61 @@ |
2106 | +/* |
2107 | + * Copyright (C) 2013 Canonical Ltd |
2108 | + * |
2109 | + * This program is free software: you can redistribute it and/or modify |
2110 | + * it under the terms of the Lesser GNU General Public License version 3 as |
2111 | + * published by the Free Software Foundation. |
2112 | + * |
2113 | + * This program is distributed in the hope that it will be useful, |
2114 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
2115 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2116 | + * Lesser GNU General Public License for more details. |
2117 | + * |
2118 | + * You should have received a copy of the Lesser GNU General Public License |
2119 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
2120 | + * |
2121 | + * Authored by: Michi Henning <michi.henning@canonical.com> |
2122 | + */ |
2123 | + |
2124 | +#ifndef UNITY_API_SCOPES_INTERNAL_MWREGISTRYPROXY_H |
2125 | +#define UNITY_API_SCOPES_INTERNAL_MWREGISTRYPROXY_H |
2126 | + |
2127 | +#include <unity/api/scopes/internal/MWObjectProxy.h> |
2128 | +#include <unity/api/scopes/RegistryProxy.h> |
2129 | +#include <unity/api/scopes/ScopeProxy.h> |
2130 | + |
2131 | +namespace unity |
2132 | +{ |
2133 | + |
2134 | +namespace api |
2135 | +{ |
2136 | + |
2137 | +namespace scopes |
2138 | +{ |
2139 | + |
2140 | +namespace internal |
2141 | +{ |
2142 | + |
2143 | +class MWRegistryProxy : public MWObjectProxy |
2144 | +{ |
2145 | +public: |
2146 | + UNITY_DEFINES_PTRS(MWRegistryProxy); |
2147 | + |
2148 | + // Remote operation implementation |
2149 | + virtual ScopeProxy::SPtr find(std::string const& scope_name) = 0; |
2150 | + virtual ScopeMap list() = 0; |
2151 | + |
2152 | + virtual ~MWRegistryProxy() noexcept; |
2153 | + |
2154 | +protected: |
2155 | + MWRegistryProxy(MiddlewareBase* mw_base); |
2156 | +}; |
2157 | + |
2158 | +} // namespace internal |
2159 | + |
2160 | +} // namespace scopes |
2161 | + |
2162 | +} // namespace api |
2163 | + |
2164 | +} // namespace unity |
2165 | + |
2166 | +#endif |
2167 | |
2168 | === added file 'include/unity/api/scopes/internal/MWReplyProxy.h' |
2169 | --- include/unity/api/scopes/internal/MWReplyProxy.h 1970-01-01 00:00:00 +0000 |
2170 | +++ include/unity/api/scopes/internal/MWReplyProxy.h 2013-08-05 06:40:36 +0000 |
2171 | @@ -0,0 +1,59 @@ |
2172 | +/* |
2173 | + * Copyright (C) 2013 Canonical Ltd |
2174 | + * |
2175 | + * This program is free software: you can redistribute it and/or modify |
2176 | + * it under the terms of the Lesser GNU General Public License version 3 as |
2177 | + * published by the Free Software Foundation. |
2178 | + * |
2179 | + * This program is distributed in the hope that it will be useful, |
2180 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
2181 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2182 | + * Lesser GNU General Public License for more details. |
2183 | + * |
2184 | + * You should have received a copy of the Lesser GNU General Public License |
2185 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
2186 | + * |
2187 | + * Authored by: Michi Henning <michi.henning@canonical.com> |
2188 | + */ |
2189 | + |
2190 | +#ifndef UNITY_API_SCOPES_INTERNAL_MWREPLYPROXY_H |
2191 | +#define UNITY_API_SCOPES_INTERNAL_MWREPLYPROXY_H |
2192 | + |
2193 | +#include <unity/api/scopes/internal/MWObjectProxy.h> |
2194 | +#include <unity/api/scopes/ReplyProxy.h> |
2195 | + |
2196 | +namespace unity |
2197 | +{ |
2198 | + |
2199 | +namespace api |
2200 | +{ |
2201 | + |
2202 | +namespace scopes |
2203 | +{ |
2204 | + |
2205 | +namespace internal |
2206 | +{ |
2207 | + |
2208 | +class MWReplyProxy : public MWObjectProxy |
2209 | +{ |
2210 | +public: |
2211 | + UNITY_DEFINES_PTRS(MWReplyProxy); |
2212 | + |
2213 | + virtual ~MWReplyProxy() noexcept; |
2214 | + |
2215 | + virtual void send(std::string const& result) = 0; |
2216 | + virtual void finished() = 0; |
2217 | + |
2218 | +protected: |
2219 | + MWReplyProxy(MiddlewareBase* mw_base); |
2220 | +}; |
2221 | + |
2222 | +} // namespace internal |
2223 | + |
2224 | +} // namespace scopes |
2225 | + |
2226 | +} // namespace api |
2227 | + |
2228 | +} // namespace unity |
2229 | + |
2230 | +#endif |
2231 | |
2232 | === added file 'include/unity/api/scopes/internal/MWScopeProxy.h' |
2233 | --- include/unity/api/scopes/internal/MWScopeProxy.h 1970-01-01 00:00:00 +0000 |
2234 | +++ include/unity/api/scopes/internal/MWScopeProxy.h 2013-08-05 06:40:36 +0000 |
2235 | @@ -0,0 +1,57 @@ |
2236 | +/* |
2237 | + * Copyright (C) 2013 Canonical Ltd |
2238 | + * |
2239 | + * This program is free software: you can redistribute it and/or modify |
2240 | + * it under the terms of the Lesser GNU General Public License version 3 as |
2241 | + * published by the Free Software Foundation. |
2242 | + * |
2243 | + * This program is distributed in the hope that it will be useful, |
2244 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
2245 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2246 | + * Lesser GNU General Public License for more details. |
2247 | + * |
2248 | + * You should have received a copy of the Lesser GNU General Public License |
2249 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
2250 | + * |
2251 | + * Authored by: Michi Henning <michi.henning@canonical.com> |
2252 | + */ |
2253 | + |
2254 | +#ifndef UNITY_API_SCOPES_INTERNAL_MWSCOPEPROXY_H |
2255 | +#define UNITY_API_SCOPES_INTERNAL_MWSCOPEPROXY_H |
2256 | + |
2257 | +#include <unity/api/scopes/internal/MWReplyProxy.h> |
2258 | + |
2259 | +namespace unity |
2260 | +{ |
2261 | + |
2262 | +namespace api |
2263 | +{ |
2264 | + |
2265 | +namespace scopes |
2266 | +{ |
2267 | + |
2268 | +namespace internal |
2269 | +{ |
2270 | + |
2271 | +class MWScopeProxy : public MWObjectProxy |
2272 | +{ |
2273 | +public: |
2274 | + UNITY_DEFINES_PTRS(MWScopeProxy); |
2275 | + |
2276 | + virtual ~MWScopeProxy() noexcept; |
2277 | + |
2278 | + virtual void query(std::string const& q, MWReplyProxy::SPtr const& reply) = 0; |
2279 | + |
2280 | +protected: |
2281 | + MWScopeProxy(MiddlewareBase* mw_base); |
2282 | +}; |
2283 | + |
2284 | +} // namespace internal |
2285 | + |
2286 | +} // namespace scopes |
2287 | + |
2288 | +} // namespace api |
2289 | + |
2290 | +} // namespace unity |
2291 | + |
2292 | +#endif |
2293 | |
2294 | === modified file 'include/unity/api/scopes/internal/MiddlewareBase.h' |
2295 | --- include/unity/api/scopes/internal/MiddlewareBase.h 2013-06-18 09:02:02 +0000 |
2296 | +++ include/unity/api/scopes/internal/MiddlewareBase.h 2013-08-05 06:40:36 +0000 |
2297 | @@ -19,8 +19,10 @@ |
2298 | #ifndef UNITY_API_SCOPES_INTERNAL_MIDDLEWAREBASE_H |
2299 | #define UNITY_API_SCOPES_INTERNAL_MIDDLEWAREBASE_H |
2300 | |
2301 | -#include <unity/util/DefinesPtrs.h> |
2302 | -#include <unity/util/NonCopyable.h> |
2303 | +#include <unity/api/scopes/internal/MWRegistryProxy.h> |
2304 | +#include <unity/api/scopes/internal/RegistryObject.h> |
2305 | +#include <unity/api/scopes/internal/ReplyObject.h> |
2306 | +#include <unity/api/scopes/internal/ScopeObject.h> |
2307 | |
2308 | namespace unity |
2309 | { |
2310 | @@ -31,21 +33,35 @@ |
2311 | namespace scopes |
2312 | { |
2313 | |
2314 | +class ScopeBase; |
2315 | + |
2316 | namespace internal |
2317 | { |
2318 | |
2319 | // Abstract base class for our middleware transport. Any control functions we need can be added here |
2320 | // as pure virtual functions. This is used by the remainder of the code to do things to the middleware |
2321 | -// without knowing which middleware it actually is (strategy pattern). |
2322 | +// without knowing which middleware it actually is. |
2323 | |
2324 | -class MiddlewareBase : public util::DefinesPtrs<MiddlewareBase>, private util::NonCopyable |
2325 | +class MiddlewareBase : private util::NonCopyable |
2326 | { |
2327 | public: |
2328 | + UNITY_DEFINES_PTRS(MiddlewareBase); |
2329 | + |
2330 | MiddlewareBase(); |
2331 | virtual ~MiddlewareBase() noexcept; |
2332 | |
2333 | - virtual void start(std::string const& scope_name) = 0; |
2334 | + virtual void start() = 0; |
2335 | virtual void stop() = 0; |
2336 | + virtual void wait_for_shutdown() = 0; |
2337 | + |
2338 | + virtual MWRegistryProxy::SPtr create_registry_proxy(std::string const& identity, std::string const& endpoint) = 0; |
2339 | + virtual MWScopeProxy::SPtr create_scope_proxy(std::string const& identity, std::string const& endpoint) = 0; |
2340 | + |
2341 | + virtual MWRegistryProxy::SPtr add_registry_object(std::string const& identity, RegistryObject::SPtr const& registry) = 0; |
2342 | + virtual MWScopeProxy::SPtr add_scope_object(std::string const& identity, ScopeObject::SPtr const& scope) = 0; |
2343 | + virtual MWReplyProxy::SPtr add_reply_object(ReplyObject::SPtr const& reply) = 0; |
2344 | + |
2345 | + virtual void remove_object(std::string const& identity) = 0; |
2346 | }; |
2347 | |
2348 | } // namespace internal |
2349 | |
2350 | === added file 'include/unity/api/scopes/internal/MiddlewareFactory.h' |
2351 | --- include/unity/api/scopes/internal/MiddlewareFactory.h 1970-01-01 00:00:00 +0000 |
2352 | +++ include/unity/api/scopes/internal/MiddlewareFactory.h 2013-08-05 06:40:36 +0000 |
2353 | @@ -0,0 +1,100 @@ |
2354 | +/* |
2355 | + * Copyright (C) 2013 Canonical Ltd |
2356 | + * |
2357 | + * This program is free software: you can redistribute it and/or modify |
2358 | + * it under the terms of the GNU General Public License version 3 as |
2359 | + * published by the Free Software Foundation. |
2360 | + * |
2361 | + * This program is distributed in the hope that it will be useful, |
2362 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
2363 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2364 | + * GNU General Public License for more details. |
2365 | + * |
2366 | + * You should have received a copy of the GNU General Public License |
2367 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
2368 | + * |
2369 | + * Authored by: Michi Henning <michi.henning@canonical.com> |
2370 | + */ |
2371 | + |
2372 | +#ifndef UNITY_API_SCOPES_INTERNAL_MIDDLEWAREFACTORY_H |
2373 | +#define UNITY_API_SCOPES_INTERNAL_MIDDLEWAREFACTORY_H |
2374 | + |
2375 | +#include <unity/api/scopes/internal/MiddlewareBase.h> |
2376 | + |
2377 | +namespace unity |
2378 | +{ |
2379 | + |
2380 | +namespace api |
2381 | +{ |
2382 | + |
2383 | +namespace scopes |
2384 | +{ |
2385 | + |
2386 | +namespace internal |
2387 | +{ |
2388 | + |
2389 | +// Factory to make middleware instances available. |
2390 | +// |
2391 | +// The lookup functions for the client-side use lazy initialization. The middleware |
2392 | +// instance is created when caller first asks for it, and the same single instance |
2393 | +// is always returned thereafter. The client-side middleware(s) are shut down when the factory |
2394 | +// is destroyed. |
2395 | +// |
2396 | +// The create functions for the server-side pass ownership to the caller. |
2397 | +// |
2398 | +// This class is thread-safe. |
2399 | + |
2400 | +class MiddlewareFactory final : private util::NonCopyable |
2401 | +{ |
2402 | +public: |
2403 | + UNITY_DEFINES_PTRS(MiddlewareFactory); |
2404 | + |
2405 | + MiddlewareFactory(std::string const& configfile); |
2406 | + ~MiddlewareFactory() noexcept; |
2407 | + |
2408 | + // Returns the middleware with the given name and kind. If that middleware hasn't been created yet, |
2409 | + // it is created first. |
2410 | + MiddlewareBase::SPtr create(std::string const& server_name, |
2411 | + std::string const& kind, |
2412 | + std::string const& configfile) const; |
2413 | + |
2414 | + // Find the middleware with the given name and kind. Returns nullptr if that middleware doesn't exist. |
2415 | + MiddlewareBase::SPtr find(std::string const& server_name, std::string const& kind) const; |
2416 | + |
2417 | +private: |
2418 | + MiddlewareBase::SPtr find_unlocked(std::string const& server_name, std::string const& kind) const; |
2419 | + |
2420 | + enum Kind { Kind_Ice, Kind_REST }; |
2421 | + static Kind to_kind(::std::string const& kind); |
2422 | + |
2423 | + struct MiddlewareData |
2424 | + { |
2425 | + std::string server_name; |
2426 | + std::string kind; |
2427 | + |
2428 | + struct Compare |
2429 | + { |
2430 | + bool operator()(MiddlewareData const& lhs, MiddlewareData const& rhs) const |
2431 | + { |
2432 | + if (lhs.server_name < rhs.server_name) |
2433 | + { |
2434 | + return true; |
2435 | + } |
2436 | + return lhs.kind < rhs.kind; |
2437 | + } |
2438 | + }; |
2439 | + }; |
2440 | + |
2441 | + mutable std::map<MiddlewareData, MiddlewareBase::SPtr, MiddlewareData::Compare> mw_map_; |
2442 | + mutable std::mutex mutex_; |
2443 | +}; |
2444 | + |
2445 | +} // namespace internal |
2446 | + |
2447 | +} // namespace scopes |
2448 | + |
2449 | +} // namespace api |
2450 | + |
2451 | +} // namespace unity |
2452 | + |
2453 | +#endif |
2454 | |
2455 | === added file 'include/unity/api/scopes/internal/MiddlewareFactoryConfig.h' |
2456 | --- include/unity/api/scopes/internal/MiddlewareFactoryConfig.h 1970-01-01 00:00:00 +0000 |
2457 | +++ include/unity/api/scopes/internal/MiddlewareFactoryConfig.h 2013-08-05 06:40:36 +0000 |
2458 | @@ -0,0 +1,60 @@ |
2459 | +/* |
2460 | + * Copyright (C) 2013 Canonical Ltd |
2461 | + * |
2462 | + * This program is free software: you can redistribute it and/or modify |
2463 | + * it under the terms of the GNU General Public License version 3 as |
2464 | + * published by the Free Software Foundation. |
2465 | + * |
2466 | + * This program is distributed in the hope that it will be useful, |
2467 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
2468 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2469 | + * GNU General Public License for more details. |
2470 | + * |
2471 | + * You should have received a copy of the GNU General Public License |
2472 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
2473 | + * |
2474 | + * Authored by: Michi Henning <michi.henning@canonical.com> |
2475 | + */ |
2476 | + |
2477 | +#ifndef UNITY_API_SCOPES_INTERNAL_MIDDLEWAREFACTORYCONFIG_H |
2478 | +#define UNITY_API_SCOPES_INTERNAL_MIDDLEWAREFACTORYCONFIG_H |
2479 | + |
2480 | +#include <unity/api/scopes/internal/ConfigBase.h> |
2481 | + |
2482 | +namespace unity |
2483 | +{ |
2484 | + |
2485 | +namespace api |
2486 | +{ |
2487 | + |
2488 | +namespace scopes |
2489 | +{ |
2490 | + |
2491 | +namespace internal |
2492 | +{ |
2493 | + |
2494 | +class MiddlewareFactoryConfig : public ConfigBase |
2495 | +{ |
2496 | +public: |
2497 | + static const char* MIDDLEWARE_FACTORY_CONFIG_GROUP; |
2498 | + |
2499 | + MiddlewareFactoryConfig(std::string const& configfile); |
2500 | + ~MiddlewareFactoryConfig() noexcept; |
2501 | + |
2502 | + std::string ice_configfile() const; |
2503 | + std::string rest_configfile() const; |
2504 | + |
2505 | +private: |
2506 | + std::string ice_configfile_; |
2507 | + std::string rest_configfile_; |
2508 | +}; |
2509 | + |
2510 | +} // namespace internal |
2511 | + |
2512 | +} // namespace scopes |
2513 | + |
2514 | +} // namespace api |
2515 | + |
2516 | +} // namespace unity |
2517 | + |
2518 | +#endif |
2519 | |
2520 | === added file 'include/unity/api/scopes/internal/ObjectProxyImpl.h' |
2521 | --- include/unity/api/scopes/internal/ObjectProxyImpl.h 1970-01-01 00:00:00 +0000 |
2522 | +++ include/unity/api/scopes/internal/ObjectProxyImpl.h 2013-08-05 06:40:36 +0000 |
2523 | @@ -0,0 +1,57 @@ |
2524 | +/* |
2525 | + * Copyright (C) 2013 Canonical Ltd |
2526 | + * |
2527 | + * This program is free software: you can redistribute it and/or modify |
2528 | + * it under the terms of the GNU General Public License version 3 as |
2529 | + * published by the Free Software Foundation. |
2530 | + * |
2531 | + * This program is distributed in the hope that it will be useful, |
2532 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
2533 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2534 | + * GNU General Public License for more details. |
2535 | + * |
2536 | + * You should have received a copy of the GNU General Public License |
2537 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
2538 | + * |
2539 | + * Authored by: Michi Henning <michi.henning@canonical.com> |
2540 | + */ |
2541 | + |
2542 | +#ifndef UNITY_INTERNAL_OBJECTPROXYIMPL_H |
2543 | +#define UNITY_INTERNAL_OBJECTPROXYIMPL_H |
2544 | + |
2545 | +#include <unity/api/scopes/internal/MWObjectProxy.h> |
2546 | +#include <unity/api/scopes/ObjectProxy.h> |
2547 | + |
2548 | +namespace unity |
2549 | +{ |
2550 | + |
2551 | +namespace api |
2552 | +{ |
2553 | + |
2554 | +namespace scopes |
2555 | +{ |
2556 | + |
2557 | +namespace internal |
2558 | +{ |
2559 | + |
2560 | +class ObjectProxyImpl final |
2561 | +{ |
2562 | +public: |
2563 | + ObjectProxyImpl(MWObjectProxy::SPtr const& mw_proxy); |
2564 | + ~ObjectProxyImpl() noexcept; |
2565 | + |
2566 | + static ObjectProxy::SPtr create(MWObjectProxy::SPtr const& mw_proxy); |
2567 | + |
2568 | +private: |
2569 | + MWObjectProxy::SPtr mw_proxy_; |
2570 | +}; |
2571 | + |
2572 | +} // namespace internal |
2573 | + |
2574 | +} // namespace scopes |
2575 | + |
2576 | +} // namespace api |
2577 | + |
2578 | +} // namespace unity |
2579 | + |
2580 | +#endif |
2581 | |
2582 | === added file 'include/unity/api/scopes/internal/RegistryConfig.h' |
2583 | --- include/unity/api/scopes/internal/RegistryConfig.h 1970-01-01 00:00:00 +0000 |
2584 | +++ include/unity/api/scopes/internal/RegistryConfig.h 2013-08-05 06:40:36 +0000 |
2585 | @@ -0,0 +1,64 @@ |
2586 | +/* |
2587 | + * Copyright (C) 2013 Canonical Ltd |
2588 | + * |
2589 | + * This program is free software: you can redistribute it and/or modify |
2590 | + * it under the terms of the GNU General Public License version 3 as |
2591 | + * published by the Free Software Foundation. |
2592 | + * |
2593 | + * This program is distributed in the hope that it will be useful, |
2594 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
2595 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2596 | + * GNU General Public License for more details. |
2597 | + * |
2598 | + * You should have received a copy of the GNU General Public License |
2599 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
2600 | + * |
2601 | + * Authored by: Michi Henning <michi.henning@canonical.com> |
2602 | + */ |
2603 | + |
2604 | +#ifndef UNITY_API_SCOPES_INTERNAL_REGISTRYCONFIG_H |
2605 | +#define UNITY_API_SCOPES_INTERNAL_REGISTRYCONFIG_H |
2606 | + |
2607 | +#include <unity/api/scopes/internal/ConfigBase.h> |
2608 | + |
2609 | +namespace unity |
2610 | +{ |
2611 | + |
2612 | +namespace api |
2613 | +{ |
2614 | + |
2615 | +namespace scopes |
2616 | +{ |
2617 | + |
2618 | +namespace internal |
2619 | +{ |
2620 | + |
2621 | +class RegistryConfig : public ConfigBase |
2622 | +{ |
2623 | +public: |
2624 | + static constexpr char const* REGISTRY_CONFIG_GROUP = "Registry"; |
2625 | + |
2626 | + RegistryConfig(std::string const& identity, std::string const& configfile); |
2627 | + ~RegistryConfig() noexcept; |
2628 | + |
2629 | + std::string identity() const; |
2630 | + std::string mw_kind() const; |
2631 | + std::string endpoint() const; |
2632 | + std::string mw_configfile() const; |
2633 | + |
2634 | +private: |
2635 | + std::string identity_; |
2636 | + std::string mw_kind_; |
2637 | + std::string endpoint_; |
2638 | + std::string mw_configfile_; |
2639 | +}; |
2640 | + |
2641 | +} // namespace internal |
2642 | + |
2643 | +} // namespace scopes |
2644 | + |
2645 | +} // namespace api |
2646 | + |
2647 | +} // namespace unity |
2648 | + |
2649 | +#endif |
2650 | |
2651 | === added file 'include/unity/api/scopes/internal/RegistryObject.h' |
2652 | --- include/unity/api/scopes/internal/RegistryObject.h 1970-01-01 00:00:00 +0000 |
2653 | +++ include/unity/api/scopes/internal/RegistryObject.h 2013-08-05 06:40:36 +0000 |
2654 | @@ -0,0 +1,71 @@ |
2655 | +/* |
2656 | + * Copyright (C) 2013 Canonical Ltd |
2657 | + * |
2658 | + * This program is free software: you can redistribute it and/or modify |
2659 | + * it under the terms of the GNU General Public License version 3 as |
2660 | + * published by the Free Software Foundation. |
2661 | + * |
2662 | + * This program is distributed in the hope that it will be useful, |
2663 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
2664 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2665 | + * GNU General Public License for more details. |
2666 | + * |
2667 | + * You should have received a copy of the GNU General Public License |
2668 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
2669 | + * |
2670 | + * Authored by: Michi Henning <michi.henning@canonical.com> |
2671 | + */ |
2672 | + |
2673 | +#ifndef UNITY_API_SCOPES_INTERNAL_REGISTRYOBJECT_H |
2674 | +#define UNITY_API_SCOPES_INTERNAL_REGISTRYOBJECT_H |
2675 | + |
2676 | +#include <unity/api/scopes/internal/AbstractObject.h> |
2677 | +#include <unity/api/scopes/internal/MWScopeProxy.h> |
2678 | + |
2679 | +#include <map> |
2680 | +#include <mutex> |
2681 | + |
2682 | +namespace unity |
2683 | +{ |
2684 | + |
2685 | +namespace api |
2686 | +{ |
2687 | + |
2688 | +namespace scopes |
2689 | +{ |
2690 | + |
2691 | +namespace internal |
2692 | +{ |
2693 | + |
2694 | +class RegistryObject final : public AbstractObject |
2695 | +{ |
2696 | +public: |
2697 | + UNITY_DEFINES_PTRS(RegistryObject); |
2698 | + |
2699 | + RegistryObject(); |
2700 | + virtual ~RegistryObject() noexcept; |
2701 | + |
2702 | + // Remote operation implementations |
2703 | + MWScopeProxy::SPtr find(std::string const& scope_name); |
2704 | + |
2705 | + typedef std::map<std::string, MWScopeProxy::SPtr> MWScopeMap; |
2706 | + MWScopeMap list(); |
2707 | + |
2708 | + // Local operations to modify the map |
2709 | + void add(std::string const& scope_name, MWScopeProxy::SPtr const& scope); |
2710 | + void remove(std::string const& scope_name); |
2711 | + |
2712 | +private: |
2713 | + mutable MWScopeMap scopes_; |
2714 | + mutable std::mutex mutex_; |
2715 | +}; |
2716 | + |
2717 | +} // namespace internal |
2718 | + |
2719 | +} // namespace scopes |
2720 | + |
2721 | +} // namespace api |
2722 | + |
2723 | +} // namespace unity |
2724 | + |
2725 | +#endif |
2726 | |
2727 | === added file 'include/unity/api/scopes/internal/RegistryProxyImpl.h' |
2728 | --- include/unity/api/scopes/internal/RegistryProxyImpl.h 1970-01-01 00:00:00 +0000 |
2729 | +++ include/unity/api/scopes/internal/RegistryProxyImpl.h 2013-08-05 06:40:36 +0000 |
2730 | @@ -0,0 +1,66 @@ |
2731 | +/* |
2732 | + * Copyright (C) 2013 Canonical Ltd |
2733 | + * |
2734 | + * This program is free software: you can redistribute it and/or modify |
2735 | + * it under the terms of the GNU General Public License version 3 as |
2736 | + * published by the Free Software Foundation. |
2737 | + * |
2738 | + * This program is distributed in the hope that it will be useful, |
2739 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
2740 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2741 | + * GNU General Public License for more details. |
2742 | + * |
2743 | + * You should have received a copy of the GNU General Public License |
2744 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
2745 | + * |
2746 | + * Authored by: Michi Henning <michi.henning@canonical.com> |
2747 | + */ |
2748 | + |
2749 | +#ifndef UNITY_INTERNAL_REGISTRYPROXYIMPL_H |
2750 | +#define UNITY_INTERNAL_REGISTRYPROXYIMPL_H |
2751 | + |
2752 | +#include <unity/api/scopes/internal/MWRegistryProxy.h> |
2753 | +#include <unity/api/scopes/RegistryProxy.h> |
2754 | + |
2755 | +#include <atomic> |
2756 | + |
2757 | +namespace unity |
2758 | +{ |
2759 | + |
2760 | +namespace api |
2761 | +{ |
2762 | + |
2763 | +namespace scopes |
2764 | +{ |
2765 | + |
2766 | +namespace internal |
2767 | +{ |
2768 | + |
2769 | +class RuntimeImpl; |
2770 | + |
2771 | +class RegistryProxyImpl final |
2772 | +{ |
2773 | +public: |
2774 | + UNITY_DEFINES_PTRS(RegistryProxyImpl); |
2775 | + |
2776 | + RegistryProxyImpl(MWRegistryProxy::SPtr const& mw_proxy); |
2777 | + ~RegistryProxyImpl() noexcept; |
2778 | + |
2779 | + ScopeProxy::SPtr find(std::string const& scope_name); |
2780 | + ScopeMap list(); |
2781 | + |
2782 | + static RegistryProxy::SPtr create(MWRegistryProxy::SPtr const& mw_proxy); |
2783 | + |
2784 | +private: |
2785 | + MWRegistryProxy::SPtr mw_proxy_; |
2786 | +}; |
2787 | + |
2788 | +} // namespace internal |
2789 | + |
2790 | +} // namespace scopes |
2791 | + |
2792 | +} // namespace api |
2793 | + |
2794 | +} // namespace unity |
2795 | + |
2796 | +#endif |
2797 | |
2798 | === added file 'include/unity/api/scopes/internal/ReplyObject.h' |
2799 | --- include/unity/api/scopes/internal/ReplyObject.h 1970-01-01 00:00:00 +0000 |
2800 | +++ include/unity/api/scopes/internal/ReplyObject.h 2013-08-05 06:40:36 +0000 |
2801 | @@ -0,0 +1,68 @@ |
2802 | +/* |
2803 | + * Copyright (C) 2013 Canonical Ltd |
2804 | + * |
2805 | + * This program is free software: you can redistribute it and/or modify |
2806 | + * it under the terms of the GNU General Public License version 3 as |
2807 | + * published by the Free Software Foundation. |
2808 | + * |
2809 | + * This program is distributed in the hope that it will be useful, |
2810 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
2811 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2812 | + * GNU General Public License for more details. |
2813 | + * |
2814 | + * You should have received a copy of the GNU General Public License |
2815 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
2816 | + * |
2817 | + * Authored by: Michi Henning <michi.henning@canonical.com> |
2818 | + */ |
2819 | + |
2820 | +#ifndef UNITY_API_REPLYS_INTERNAL_REPLYOBJECT_H |
2821 | +#define UNITY_API_REPLYS_INTERNAL_REPLYOBJECT_H |
2822 | + |
2823 | +#include <unity/api/scopes/internal/AbstractObject.h> |
2824 | +#include <unity/api/scopes/ReplyBase.h> |
2825 | + |
2826 | +#include <atomic> |
2827 | + |
2828 | +namespace unity |
2829 | +{ |
2830 | + |
2831 | +namespace api |
2832 | +{ |
2833 | + |
2834 | +namespace scopes |
2835 | +{ |
2836 | + |
2837 | +namespace internal |
2838 | +{ |
2839 | + |
2840 | +// A ReplyObject sits in between the incoming requests from the middleware layer and the |
2841 | +// ReplyBase-derived implementation provided by the scope. |
2842 | +// This allows us to intercept all replies. |
2843 | + |
2844 | +class ReplyObject final : public AbstractObject |
2845 | +{ |
2846 | +public: |
2847 | + UNITY_DEFINES_PTRS(ReplyObject); |
2848 | + |
2849 | + ReplyObject(ReplyBase::SPtr const& reply_base); |
2850 | + virtual ~ReplyObject() noexcept; |
2851 | + |
2852 | + // Remote operation implementations |
2853 | + void send(std::string const& result); |
2854 | + void finished(); |
2855 | + |
2856 | +private: |
2857 | + ReplyBase::SPtr reply_base_; |
2858 | + std::atomic_bool finished_; |
2859 | +}; |
2860 | + |
2861 | +} // namespace internal |
2862 | + |
2863 | +} // namespace scopes |
2864 | + |
2865 | +} // namespace api |
2866 | + |
2867 | +} // namespace unity |
2868 | + |
2869 | +#endif |
2870 | |
2871 | === added file 'include/unity/api/scopes/internal/ReplyProxyImpl.h' |
2872 | --- include/unity/api/scopes/internal/ReplyProxyImpl.h 1970-01-01 00:00:00 +0000 |
2873 | +++ include/unity/api/scopes/internal/ReplyProxyImpl.h 2013-08-05 06:40:36 +0000 |
2874 | @@ -0,0 +1,68 @@ |
2875 | +/* |
2876 | + * Copyright (C) 2013 Canonical Ltd |
2877 | + * |
2878 | + * This program is free software: you can redistribute it and/or modify |
2879 | + * it under the terms of the GNU General Public License version 3 as |
2880 | + * published by the Free Software Foundation. |
2881 | + * |
2882 | + * This program is distributed in the hope that it will be useful, |
2883 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
2884 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2885 | + * GNU General Public License for more details. |
2886 | + * |
2887 | + * You should have received a copy of the GNU General Public License |
2888 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
2889 | + * |
2890 | + * Authored by: Michi Henning <michi.henning@canonical.com> |
2891 | + */ |
2892 | + |
2893 | +#ifndef UNITY_INTERNAL_REPLYPROXYIMPL_H |
2894 | +#define UNITY_INTERNAL_REPLYPROXYIMPL_H |
2895 | + |
2896 | +#include <unity/api/scopes/internal/MWReplyProxy.h> |
2897 | + |
2898 | +#include <atomic> |
2899 | + |
2900 | +namespace unity |
2901 | +{ |
2902 | + |
2903 | +namespace api |
2904 | +{ |
2905 | + |
2906 | +namespace scopes |
2907 | +{ |
2908 | + |
2909 | +namespace internal |
2910 | +{ |
2911 | + |
2912 | +// Proxy used by a scope to push results for a query. |
2913 | +// To indicate that it has sent the last result, the scope must call finished(). |
2914 | +// Subsequent calls to finished() are ignored. |
2915 | +// Calls to send() after finished() was called are ignored. |
2916 | +// If the proxy goes out of scope before finished was called, it implicitly calls finished(). |
2917 | + |
2918 | +class ReplyProxyImpl final |
2919 | +{ |
2920 | +public: |
2921 | + ReplyProxyImpl(MWReplyProxy::SPtr const& mw_proxy); |
2922 | + ~ReplyProxyImpl() noexcept; |
2923 | + |
2924 | + void send(std::string const& result); |
2925 | + void finished(); |
2926 | + |
2927 | + static ReplyProxy::SPtr create(MWReplyProxy::SPtr const& mw_proxy); |
2928 | + |
2929 | +private: |
2930 | + MWReplyProxy::SPtr mw_proxy_; |
2931 | + std::atomic_bool finished_; |
2932 | +}; |
2933 | + |
2934 | +} // namespace internal |
2935 | + |
2936 | +} // namespace scopes |
2937 | + |
2938 | +} // namespace api |
2939 | + |
2940 | +} // namespace unity |
2941 | + |
2942 | +#endif |
2943 | |
2944 | === added file 'include/unity/api/scopes/internal/RuntimeConfig.h' |
2945 | --- include/unity/api/scopes/internal/RuntimeConfig.h 1970-01-01 00:00:00 +0000 |
2946 | +++ include/unity/api/scopes/internal/RuntimeConfig.h 2013-08-05 06:40:36 +0000 |
2947 | @@ -0,0 +1,65 @@ |
2948 | +/* |
2949 | + * Copyright (C) 2013 Canonical Ltd |
2950 | + * |
2951 | + * This program is free software: you can redistribute it and/or modify |
2952 | + * it under the terms of the GNU General Public License version 3 as |
2953 | + * published by the Free Software Foundation. |
2954 | + * |
2955 | + * This program is distributed in the hope that it will be useful, |
2956 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
2957 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2958 | + * GNU General Public License for more details. |
2959 | + * |
2960 | + * You should have received a copy of the GNU General Public License |
2961 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
2962 | + * |
2963 | + * Authored by: Michi Henning <michi.henning@canonical.com> |
2964 | + */ |
2965 | + |
2966 | +#ifndef UNITY_API_SCOPES_INTERNAL_RUNTIMECONFIG_H |
2967 | +#define UNITY_API_SCOPES_INTERNAL_RUNTIMECONFIG_H |
2968 | + |
2969 | +#include <unity/api/scopes/internal/ConfigBase.h> |
2970 | +#include <unity/api/scopes/Runtime.h> |
2971 | + |
2972 | +namespace unity |
2973 | +{ |
2974 | + |
2975 | +namespace api |
2976 | +{ |
2977 | + |
2978 | +namespace scopes |
2979 | +{ |
2980 | + |
2981 | +namespace internal |
2982 | +{ |
2983 | + |
2984 | +class RuntimeConfig : public ConfigBase |
2985 | +{ |
2986 | +public: |
2987 | + static const char* RUNTIME_CONFIG_GROUP; |
2988 | + |
2989 | + RuntimeConfig(std::string const& configfile = Runtime::DFLT_CONFIGFILE); |
2990 | + ~RuntimeConfig() noexcept; |
2991 | + |
2992 | + std::string registry_identity() const; |
2993 | + std::string registry_configfile() const; |
2994 | + std::string default_middleware() const; |
2995 | + std::string factory_configfile() const; |
2996 | + |
2997 | +private: |
2998 | + std::string registry_identity_; |
2999 | + std::string registry_configfile_; |
3000 | + std::string default_middleware_; |
3001 | + std::string factory_configfile_; |
3002 | +}; |
3003 | + |
3004 | +} // namespace internal |
3005 | + |
3006 | +} // namespace scopes |
3007 | + |
3008 | +} // namespace api |
3009 | + |
3010 | +} // namespace unity |
3011 | + |
3012 | +#endif |
3013 | |
3014 | === added file 'include/unity/api/scopes/internal/RuntimeImpl.h' |
3015 | --- include/unity/api/scopes/internal/RuntimeImpl.h 1970-01-01 00:00:00 +0000 |
3016 | +++ include/unity/api/scopes/internal/RuntimeImpl.h 2013-08-05 06:40:36 +0000 |
3017 | @@ -0,0 +1,72 @@ |
3018 | +/* |
3019 | + * Copyright (C) 2013 Canonical Ltd |
3020 | + * |
3021 | + * This program is free software: you can redistribute it and/or modify |
3022 | + * it under the terms of the GNU General Public License version 3 as |
3023 | + * published by the Free Software Foundation. |
3024 | + * |
3025 | + * This program is distributed in the hope that it will be useful, |
3026 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
3027 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3028 | + * GNU General Public License for more details. |
3029 | + * |
3030 | + * You should have received a copy of the GNU General Public License |
3031 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
3032 | + * |
3033 | + * Authored by: Michi Henning <michi.henning@canonical.com> |
3034 | + */ |
3035 | + |
3036 | +#ifndef UNITY_API_SCOPES_INTERNAL_RUNTIMEIMPL_H |
3037 | +#define UNITY_API_SCOPES_INTERNAL_RUNTIMEIMPL_H |
3038 | + |
3039 | +#include <unity/api/scopes/internal/MiddlewareBase.h> |
3040 | +#include <unity/api/scopes/internal/MiddlewareFactory.h> |
3041 | +#include <unity/api/scopes/Runtime.h> |
3042 | + |
3043 | +#include <atomic> |
3044 | + |
3045 | +namespace unity |
3046 | +{ |
3047 | + |
3048 | +namespace api |
3049 | +{ |
3050 | + |
3051 | +namespace scopes |
3052 | +{ |
3053 | + |
3054 | +namespace internal |
3055 | +{ |
3056 | + |
3057 | +class RuntimeImpl final : private util::NonCopyable |
3058 | +{ |
3059 | +public: |
3060 | + UNITY_DEFINES_PTRS(RuntimeImpl); |
3061 | + |
3062 | + static UPtr create(std::string const& scope_name, std::string const& configfile = Runtime::DFLT_CONFIGFILE); |
3063 | + void destroy(); |
3064 | + |
3065 | + MiddlewareFactory const* factory() const; |
3066 | + RegistryProxy::SPtr registry() const; |
3067 | + std::string registry_configfile() const; |
3068 | + |
3069 | + ~RuntimeImpl() noexcept; |
3070 | + |
3071 | +private: |
3072 | + RuntimeImpl(std::string const& scope_name, std::string const& configfile); |
3073 | + |
3074 | + std::atomic_bool destroyed_; |
3075 | + MiddlewareFactory::UPtr middleware_factory_; |
3076 | + MiddlewareBase::SPtr middleware_; |
3077 | + mutable RegistryProxy::SPtr registry_; |
3078 | + mutable std::string registry_configfile_; |
3079 | +}; |
3080 | + |
3081 | +} // namespace internal |
3082 | + |
3083 | +} // namespace scopes |
3084 | + |
3085 | +} // namespace api |
3086 | + |
3087 | +} // namespace unity |
3088 | + |
3089 | +#endif |
3090 | |
3091 | === added file 'include/unity/api/scopes/internal/ScopeExceptionsImpl.h' |
3092 | --- include/unity/api/scopes/internal/ScopeExceptionsImpl.h 1970-01-01 00:00:00 +0000 |
3093 | +++ include/unity/api/scopes/internal/ScopeExceptionsImpl.h 2013-08-05 06:40:36 +0000 |
3094 | @@ -0,0 +1,65 @@ |
3095 | +/* |
3096 | + * Copyright (C) 2013 Canonical Ltd |
3097 | + * |
3098 | + * This program is free software: you can redistribute it and/or modify |
3099 | + * it under the terms of the GNU General Public License version 3 as |
3100 | + * published by the Free Software Foundation. |
3101 | + * |
3102 | + * This program is distributed in the hope that it will be useful, |
3103 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
3104 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3105 | + * GNU General Public License for more details. |
3106 | + * |
3107 | + * You should have received a copy of the GNU General Public License |
3108 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
3109 | + * |
3110 | + * Authored by: Michi Henning <michi.henning@canonical.com> |
3111 | + */ |
3112 | + |
3113 | +#ifndef UNITY_INTERNAL_SCOPEEXCEPTIONSIMPL_H |
3114 | +#define UNITY_INTERNAL_SCOPEEXCEPTIONSIMPL_H |
3115 | + |
3116 | +#include <unity/Exception.h> |
3117 | + |
3118 | +#include <string> |
3119 | +#include <exception> |
3120 | + |
3121 | +namespace unity |
3122 | +{ |
3123 | + |
3124 | +class Exception; |
3125 | + |
3126 | +namespace api |
3127 | +{ |
3128 | + |
3129 | +namespace scopes |
3130 | +{ |
3131 | + |
3132 | +namespace internal |
3133 | +{ |
3134 | + |
3135 | +class MiddlewareExceptionImpl : public Exception |
3136 | +{ |
3137 | +public: |
3138 | + MiddlewareExceptionImpl(std::string const& reason); |
3139 | + |
3140 | + virtual char const* what() const noexcept override; |
3141 | +}; |
3142 | + |
3143 | +class ConfigExceptionImpl : public Exception |
3144 | +{ |
3145 | +public: |
3146 | + ConfigExceptionImpl(std::string const& reason); |
3147 | + |
3148 | + virtual char const* what() const noexcept override; |
3149 | +}; |
3150 | + |
3151 | +} // namespace internal |
3152 | + |
3153 | +} // namespace scopes |
3154 | + |
3155 | +} // namespace api |
3156 | + |
3157 | +} // namespace unity |
3158 | + |
3159 | +#endif |
3160 | |
3161 | === modified file 'include/unity/api/scopes/internal/ScopeLoader.h' |
3162 | --- include/unity/api/scopes/internal/ScopeLoader.h 2013-07-02 21:36:00 +0000 |
3163 | +++ include/unity/api/scopes/internal/ScopeLoader.h 2013-08-05 06:40:36 +0000 |
3164 | @@ -21,7 +21,6 @@ |
3165 | |
3166 | #include <unity/api/scopes/ScopeBase.h> |
3167 | #include <unity/api/scopes/internal/DynamicLoader.h> |
3168 | -#include <unity/api/scopes/internal/MiddlewareBase.h> |
3169 | |
3170 | #include <thread> |
3171 | #include <condition_variable> |
3172 | @@ -38,37 +37,78 @@ |
3173 | namespace internal |
3174 | { |
3175 | |
3176 | -class ScopeLoader final : public unity::util::DefinesPtrs<ScopeLoader> |
3177 | +// ScopeLoader loads the .so for a scope and TODO: complete this and updated comments below. |
3178 | + |
3179 | +class UNITY_API ScopeLoader final : public util::NonCopyable |
3180 | { |
3181 | public: |
3182 | - static UPtr load(std::string const& scope_name, std::string const& path, MiddlewareBase::SPtr& middleware); |
3183 | - void unload() noexcept; |
3184 | - |
3185 | + UNITY_DEFINES_PTRS(ScopeLoader); |
3186 | + |
3187 | + // Creates a ScopeLoader for a scope with the given name and library. We pass in the registry proxy |
3188 | + // so we can pass it to the scope's start method. |
3189 | + static UPtr load(std::string const& scope_name, std::string const& libpath, RegistryProxy::SPtr const& registry); |
3190 | + |
3191 | + // unload() explicitly finalizes the scope. This is called by the destructor too, but calling it explicity |
3192 | + // allows the caller to receive any exceptions that may have been produced by the scope thread. |
3193 | + void unload(); |
3194 | + |
3195 | + // These methods start or stop a scope. They are asynchronous, that is, they don't wait until the scope is |
3196 | + // started or stopped; instead they just instruct the scope to do what it is told without waiting. |
3197 | void start(); |
3198 | void stop(); |
3199 | |
3200 | + // Returns the scope name |
3201 | std::string name() const noexcept; |
3202 | + |
3203 | + // Returns the library path for the scope |
3204 | std::string libpath() const noexcept; |
3205 | |
3206 | + // Returns the actual implementation provided by the scope. |
3207 | + unity::api::scopes::ScopeBase* scope_base() const; |
3208 | + |
3209 | ~ScopeLoader() noexcept; |
3210 | |
3211 | private: |
3212 | - ScopeLoader(std::string const& name, std::string const& path, MiddlewareBase::SPtr& middleware); |
3213 | + ScopeLoader(std::string const& name, std::string const& path, RegistryProxy::SPtr const& registry); |
3214 | void run_scope(unity::api::scopes::CreateFunction create_func, unity::api::scopes::DestroyFunction destroy_func); |
3215 | void handle_thread_exception(); |
3216 | |
3217 | + void run_application(unity::api::scopes::ScopeBase* scope); |
3218 | + void notify_app_thread_started(); |
3219 | + |
3220 | std::string scope_name_; |
3221 | + unity::api::scopes::ScopeBase* scope_base_; |
3222 | unity::api::scopes::internal::DynamicLoader::UPtr dyn_loader_; |
3223 | - unity::api::scopes::internal::MiddlewareBase::SPtr middleware_; |
3224 | + unity::api::scopes::RegistryProxy::SPtr registry_; |
3225 | + std::exception_ptr exception_; |
3226 | + |
3227 | std::thread scope_thread_; |
3228 | |
3229 | - enum class ScopeState { Created, Stopped, Started, Finished, Failed }; |
3230 | + enum class ScopeState |
3231 | + { |
3232 | + Created, Stopped, Started, Finished, Failed |
3233 | + }; |
3234 | ScopeState scope_state_; |
3235 | std::condition_variable state_changed_; |
3236 | - enum class ScopeCmd { None, Start, Stop, Finish }; |
3237 | - ScopeCmd scope_cmd_; |
3238 | + mutable std::mutex state_mutex_; |
3239 | + |
3240 | + enum class ScopeCmd |
3241 | + { |
3242 | + None, Start, Stop, Finish |
3243 | + }; |
3244 | + ScopeCmd cmd_; |
3245 | std::condition_variable cmd_changed_; |
3246 | - std::mutex mutex_; |
3247 | + std::mutex cmd_mutex_; |
3248 | + |
3249 | + std::thread run_thread_; |
3250 | + |
3251 | + enum class AppState |
3252 | + { |
3253 | + Created, Started, Stopped |
3254 | + }; |
3255 | + AppState run_thread_state_; |
3256 | + std::condition_variable run_thread_changed_; |
3257 | + std::mutex run_thread_mutex_; |
3258 | }; |
3259 | |
3260 | } // namespace internal |
3261 | |
3262 | === added file 'include/unity/api/scopes/internal/ScopeLoader.h.bak' |
3263 | --- include/unity/api/scopes/internal/ScopeLoader.h.bak 1970-01-01 00:00:00 +0000 |
3264 | +++ include/unity/api/scopes/internal/ScopeLoader.h.bak 2013-08-05 06:40:36 +0000 |
3265 | @@ -0,0 +1,96 @@ |
3266 | +/* |
3267 | + * Copyright (C) 2013 Canonical Ltd |
3268 | + * |
3269 | + * This program is free software: you can redistribute it and/or modify |
3270 | + * it under the terms of the GNU General Public License version 3 as |
3271 | + * published by the Free Software Foundation. |
3272 | + * |
3273 | + * This program is distributed in the hope that it will be useful, |
3274 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
3275 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3276 | + * GNU General Public License for more details. |
3277 | + * |
3278 | + * You should have received a copy of the GNU General Public License |
3279 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
3280 | + * |
3281 | + * Authored by: Michi Henning <michi.henning@canonical.com> |
3282 | + */ |
3283 | + |
3284 | +#ifndef UNITY_API_SCOPES_INTERNAL_SCOPELOADER_H |
3285 | +#define UNITY_API_SCOPES_INTERNAL_SCOPELOADER_H |
3286 | + |
3287 | +#include <unity/api/scopes/ScopeBase.h> |
3288 | +#include <unity/api/scopes/internal/DynamicLoader.h> |
3289 | +#include <unity/api/scopes/internal/MiddlewareBase.h> |
3290 | + |
3291 | +#include <thread> |
3292 | +#include <condition_variable> |
3293 | + |
3294 | +namespace unity |
3295 | +{ |
3296 | + |
3297 | +namespace api |
3298 | +{ |
3299 | + |
3300 | +namespace scopes |
3301 | +{ |
3302 | + |
3303 | +namespace internal |
3304 | +{ |
3305 | + |
3306 | +// ScopeLoader loads the .so for a scope and initializes the middleware that is used to communicate with |
3307 | +// the scope. |
3308 | + |
3309 | +class ScopeLoader final |
3310 | +{ |
3311 | +public: |
3312 | + UNITY_DEFINES_PTRS(ScopeLoader); |
3313 | + |
3314 | + static UPtr load(std::string const& scope_name, std::string const& libpath, MiddlewareBase::SPtr& middleware); |
3315 | + void unload(); |
3316 | + |
3317 | + void start(); |
3318 | + void stop(); |
3319 | + |
3320 | + std::string name() const noexcept; |
3321 | + std::string libpath() const noexcept; |
3322 | + |
3323 | + ~ScopeLoader() noexcept; |
3324 | + |
3325 | +private: |
3326 | + ScopeLoader(std::string const& name, std::string const& path, MiddlewareBase::SPtr& middleware); |
3327 | + void run_scope(unity::api::scopes::CreateFunction create_func, unity::api::scopes::DestroyFunction destroy_func); |
3328 | + void handle_thread_exception(); |
3329 | + |
3330 | + void run_application(MiddlewareBase* middleware, unity::api::scopes::ScopeBase* scope); |
3331 | + void notify_app_thread_started(); |
3332 | + void notify_app_thread_stopped(); |
3333 | + |
3334 | + std::string m_scope_name; |
3335 | + unity::api::scopes::internal::DynamicLoader::UPtr m_dyn_loader; |
3336 | + unity::api::scopes::internal::MiddlewareBase::SPtr m_middleware; |
3337 | + std::thread m_scope_thread; |
3338 | + std::thread m_application_thread; |
3339 | + |
3340 | + enum class ScopeState { Created, Stopped, Started, Finished, Failed }; |
3341 | + ScopeState m_scope_state; |
3342 | + std::condition_variable m_state_changed; |
3343 | + enum class ScopeCmd { None, Start, Stop, Finish }; |
3344 | + ScopeCmd m_scope_cmd; |
3345 | + std::condition_variable m_cmd_changed; |
3346 | + std::mutex m_mutex; |
3347 | + |
3348 | + bool m_app_thread_running; |
3349 | + std::condition_variable m_app_thread_changed; |
3350 | + std::mutex m_app_thread_mutex; |
3351 | +}; |
3352 | + |
3353 | +} // namespace internal |
3354 | + |
3355 | +} // namespace scopes |
3356 | + |
3357 | +} // namespace api |
3358 | + |
3359 | +} // namespace unity |
3360 | + |
3361 | +#endif |
3362 | |
3363 | === added file 'include/unity/api/scopes/internal/ScopeObject.h' |
3364 | --- include/unity/api/scopes/internal/ScopeObject.h 1970-01-01 00:00:00 +0000 |
3365 | +++ include/unity/api/scopes/internal/ScopeObject.h 2013-08-05 06:40:36 +0000 |
3366 | @@ -0,0 +1,66 @@ |
3367 | +/* |
3368 | + * Copyright (C) 2013 Canonical Ltd |
3369 | + * |
3370 | + * This program is free software: you can redistribute it and/or modify |
3371 | + * it under the terms of the GNU General Public License version 3 as |
3372 | + * published by the Free Software Foundation. |
3373 | + * |
3374 | + * This program is distributed in the hope that it will be useful, |
3375 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
3376 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3377 | + * GNU General Public License for more details. |
3378 | + * |
3379 | + * You should have received a copy of the GNU General Public License |
3380 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
3381 | + * |
3382 | + * Authored by: Michi Henning <michi.henning@canonical.com> |
3383 | + */ |
3384 | + |
3385 | +#ifndef UNITY_API_SCOPES_INTERNAL_SCOPEOBJECT_H |
3386 | +#define UNITY_API_SCOPES_INTERNAL_SCOPEOBJECT_H |
3387 | + |
3388 | +#include <unity/api/scopes/internal/AbstractObject.h> |
3389 | +#include <unity/api/scopes/ReplyProxy.h> |
3390 | + |
3391 | +namespace unity |
3392 | +{ |
3393 | + |
3394 | +namespace api |
3395 | +{ |
3396 | + |
3397 | +namespace scopes |
3398 | +{ |
3399 | + |
3400 | +class ScopeBase; |
3401 | + |
3402 | +namespace internal |
3403 | +{ |
3404 | + |
3405 | +// A ScopeObject sits in between the incoming requests from the middleware layer and the |
3406 | +// ScopeBase-derived implementation provided by the scope. It forwards incoming |
3407 | +// queries to the actual scope. This allows us to intercept all queries for a scope. |
3408 | + |
3409 | +class ScopeObject final : public AbstractObject |
3410 | +{ |
3411 | +public: |
3412 | + UNITY_DEFINES_PTRS(ScopeObject); |
3413 | + |
3414 | + ScopeObject(ScopeBase* scope_base_); |
3415 | + virtual ~ScopeObject() noexcept; |
3416 | + |
3417 | + // Remote operation implementations |
3418 | + void query(std::string const& q, ReplyProxy::SPtr const& reply); |
3419 | + |
3420 | +private: |
3421 | + ScopeBase* scope_base_; |
3422 | +}; |
3423 | + |
3424 | +} // namespace internal |
3425 | + |
3426 | +} // namespace scopes |
3427 | + |
3428 | +} // namespace api |
3429 | + |
3430 | +} // namespace unity |
3431 | + |
3432 | +#endif |
3433 | |
3434 | === added file 'include/unity/api/scopes/internal/ScopeProxyImpl.h' |
3435 | --- include/unity/api/scopes/internal/ScopeProxyImpl.h 1970-01-01 00:00:00 +0000 |
3436 | +++ include/unity/api/scopes/internal/ScopeProxyImpl.h 2013-08-05 06:40:36 +0000 |
3437 | @@ -0,0 +1,61 @@ |
3438 | +/* |
3439 | + * Copyright (C) 2013 Canonical Ltd |
3440 | + * |
3441 | + * This program is free software: you can redistribute it and/or modify |
3442 | + * it under the terms of the GNU General Public License version 3 as |
3443 | + * published by the Free Software Foundation. |
3444 | + * |
3445 | + * This program is distributed in the hope that it will be useful, |
3446 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
3447 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3448 | + * GNU General Public License for more details. |
3449 | + * |
3450 | + * You should have received a copy of the GNU General Public License |
3451 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
3452 | + * |
3453 | + * Authored by: Michi Henning <michi.henning@canonical.com> |
3454 | + */ |
3455 | + |
3456 | +#ifndef UNITY_INTERNAL_SCOPEPROXYIMPL_H |
3457 | +#define UNITY_INTERNAL_SCOPEPROXYIMPL_H |
3458 | + |
3459 | +#include <unity/api/scopes/internal/MWScopeProxy.h> |
3460 | +#include <unity/api/scopes/ScopeProxy.h> |
3461 | + |
3462 | +namespace unity |
3463 | +{ |
3464 | + |
3465 | +namespace api |
3466 | +{ |
3467 | + |
3468 | +namespace scopes |
3469 | +{ |
3470 | + |
3471 | +namespace internal |
3472 | +{ |
3473 | + |
3474 | +class RuntimeImpl; |
3475 | + |
3476 | +class ScopeProxyImpl final |
3477 | +{ |
3478 | +public: |
3479 | + ScopeProxyImpl(MWScopeProxy::SPtr const& mw_proxy); |
3480 | + ~ScopeProxyImpl() noexcept; |
3481 | + |
3482 | + void query(std::string const& q, ReplyBase::SPtr const& reply) const; |
3483 | + |
3484 | + static ScopeProxy::SPtr create(MWScopeProxy::SPtr const& mw_proxy); |
3485 | + |
3486 | +private: |
3487 | + MWScopeProxy::SPtr mw_proxy_; |
3488 | +}; |
3489 | + |
3490 | +} // namespace internal |
3491 | + |
3492 | +} // namespace scopes |
3493 | + |
3494 | +} // namespace api |
3495 | + |
3496 | +} // namespace unity |
3497 | + |
3498 | +#endif |
3499 | |
3500 | === added directory 'include/unity/api/scopes/internal/ice_middleware' |
3501 | === added file 'include/unity/api/scopes/internal/ice_middleware/CMakeLists.txt' |
3502 | --- include/unity/api/scopes/internal/ice_middleware/CMakeLists.txt 1970-01-01 00:00:00 +0000 |
3503 | +++ include/unity/api/scopes/internal/ice_middleware/CMakeLists.txt 2013-08-05 06:40:36 +0000 |
3504 | @@ -0,0 +1,3 @@ |
3505 | +file(GLOB headers "${CMAKE_CURRENT_SOURCE_DIR}/*.h") |
3506 | + |
3507 | +set(UNITY_SCOPES_LIB_HDRS ${UNITY_SCOPES_LIB_HDRS} ${headers} PARENT_SCOPE) |
3508 | |
3509 | === added file 'include/unity/api/scopes/internal/ice_middleware/IceMiddleware.h' |
3510 | --- include/unity/api/scopes/internal/ice_middleware/IceMiddleware.h 1970-01-01 00:00:00 +0000 |
3511 | +++ include/unity/api/scopes/internal/ice_middleware/IceMiddleware.h 2013-08-05 06:40:36 +0000 |
3512 | @@ -0,0 +1,85 @@ |
3513 | +/* |
3514 | + * Copyright (C) 2013 Canonical Ltd |
3515 | + * |
3516 | + * This program is free software: you can redistribute it and/or modify |
3517 | + * it under the terms of the GNU General Public License version 3 as |
3518 | + * published by the Free Software Foundation. |
3519 | + * |
3520 | + * This program is distributed in the hope that it will be useful, |
3521 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
3522 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3523 | + * GNU General Public License for more details. |
3524 | + * |
3525 | + * You should have received a copy of the GNU General Public License |
3526 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
3527 | + * |
3528 | + * Authored by: Michi Henning <michi.henning@canonical.com> |
3529 | + */ |
3530 | + |
3531 | +#ifndef UNITY_API_SCOPES_INTERNAL_ICEMIDDLEWARE_ICEMIDDLEWARE_H |
3532 | +#define UNITY_API_SCOPES_INTERNAL_ICEMIDDLEWARE_ICEMIDDLEWARE_H |
3533 | + |
3534 | +#include <unity/api/scopes/internal/ice_middleware/IceObjectProxy.h> |
3535 | +#include <unity/api/scopes/internal/ice_middleware/IceReplyProxy.h> |
3536 | +#include <unity/api/scopes/internal/MiddlewareBase.h> |
3537 | + |
3538 | +#include <Ice/CommunicatorF.h> |
3539 | +#include <Ice/ObjectAdapterF.h> |
3540 | + |
3541 | +namespace unity |
3542 | +{ |
3543 | + |
3544 | +namespace api |
3545 | +{ |
3546 | + |
3547 | +namespace scopes |
3548 | +{ |
3549 | + |
3550 | +class ScopeBase; |
3551 | + |
3552 | +namespace internal |
3553 | +{ |
3554 | + |
3555 | +namespace ice_middleware |
3556 | +{ |
3557 | + |
3558 | +class IceMiddleware : public MiddlewareBase |
3559 | +{ |
3560 | +public: |
3561 | + IceMiddleware(std::string const& server_name, std::string const& configfile); |
3562 | + virtual ~IceMiddleware() noexcept; |
3563 | + |
3564 | + virtual void start() override; |
3565 | + virtual void stop() override; |
3566 | + virtual void wait_for_shutdown() override; |
3567 | + |
3568 | + virtual MWRegistryProxy::SPtr create_registry_proxy(std::string const& identity, std::string const& endpoint) override; |
3569 | + virtual MWScopeProxy::SPtr create_scope_proxy(std::string const& identity, std::string const& endpoint) override; |
3570 | + |
3571 | + virtual MWRegistryProxy::SPtr add_registry_object(std::string const& identity, RegistryObject::SPtr const& registry) override; |
3572 | + virtual MWScopeProxy::SPtr add_scope_object(std::string const& identity, ScopeObject::SPtr const& scope) override; |
3573 | + virtual MWReplyProxy::SPtr add_reply_object(ReplyObject::SPtr const& reply) override; |
3574 | + |
3575 | + virtual void remove_object(std::string const& identity); |
3576 | + |
3577 | +private: |
3578 | + Ice::ObjectPrx safe_add(Ice::ObjectPtr const& obj, std::string const& identity = ""); |
3579 | + |
3580 | + std::string server_name_; |
3581 | + std::string configfile_; |
3582 | + Ice::CommunicatorPtr ic_; |
3583 | + Ice::ObjectAdapterPtr adapter_; |
3584 | + std::mutex mutex_; // Protects adapter_ |
3585 | +}; |
3586 | + |
3587 | +} // namespace ice_middleware |
3588 | + |
3589 | +} // namespace internal |
3590 | + |
3591 | +} // namespace scopes |
3592 | + |
3593 | +} // namespace api |
3594 | + |
3595 | +} // namespace unity |
3596 | + |
3597 | +#endif |
3598 | |
3599 | === added file 'include/unity/api/scopes/internal/ice_middleware/IceObjectProxy.h' |
3600 | --- include/unity/api/scopes/internal/ice_middleware/IceObjectProxy.h 1970-01-01 00:00:00 +0000 |
3601 | +++ include/unity/api/scopes/internal/ice_middleware/IceObjectProxy.h 2013-08-05 06:40:36 +0000 |
3602 | @@ -0,0 +1,67 @@ |
3603 | +/* |
3604 | + * Copyright (C) 2013 Canonical Ltd |
3605 | + * |
3606 | + * This program is free software: you can redistribute it and/or modify |
3607 | + * it under the terms of the Lesser GNU General Public License version 3 as |
3608 | + * published by the Free Software Foundation. |
3609 | + * |
3610 | + * This program is distributed in the hope that it will be useful, |
3611 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
3612 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3613 | + * Lesser GNU General Public License for more details. |
3614 | + * |
3615 | + * You should have received a copy of the Lesser GNU General Public License |
3616 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
3617 | + * |
3618 | + * Authored by: Michi Henning <michi.henning@canonical.com> |
3619 | + */ |
3620 | + |
3621 | +#ifndef UNITY_API_SCOPES_INTERNAL_ICEMIDDLEWARE_ICEOBJECTPROXY_H |
3622 | +#define UNITY_API_SCOPES_INTERNAL_ICEMIDDLEWARE_ICEOBJECTPROXY_H |
3623 | + |
3624 | +#include <unity/api/scopes/internal/MWObjectProxy.h> |
3625 | + |
3626 | +#include <Ice/Proxy.h> |
3627 | + |
3628 | +namespace unity |
3629 | +{ |
3630 | + |
3631 | +namespace api |
3632 | +{ |
3633 | + |
3634 | +namespace scopes |
3635 | +{ |
3636 | + |
3637 | +namespace internal |
3638 | +{ |
3639 | + |
3640 | +namespace ice_middleware |
3641 | +{ |
3642 | + |
3643 | +// An Ice proxy that points at some Ice object, but without a specific type. |
3644 | + |
3645 | +class IceObjectProxy : public MWObjectProxy |
3646 | +{ |
3647 | +public: |
3648 | + UNITY_DEFINES_PTRS(IceObjectProxy); |
3649 | + |
3650 | + IceObjectProxy(MiddlewareBase* mw_base, Ice::ObjectPrx const& p) noexcept; |
3651 | + ~IceObjectProxy() noexcept; |
3652 | + |
3653 | + Ice::ObjectPrx proxy() const noexcept; |
3654 | + |
3655 | +private: |
3656 | + Ice::ObjectPrx proxy_; |
3657 | +}; |
3658 | + |
3659 | +} // namespace ice_middleware |
3660 | + |
3661 | +} // namespace internal |
3662 | + |
3663 | +} // namespace scopes |
3664 | + |
3665 | +} // namespace api |
3666 | + |
3667 | +} // namespace unity |
3668 | + |
3669 | +#endif |
3670 | |
3671 | === added file 'include/unity/api/scopes/internal/ice_middleware/IceRegistryProxy.h' |
3672 | --- include/unity/api/scopes/internal/ice_middleware/IceRegistryProxy.h 1970-01-01 00:00:00 +0000 |
3673 | +++ include/unity/api/scopes/internal/ice_middleware/IceRegistryProxy.h 2013-08-05 06:40:36 +0000 |
3674 | @@ -0,0 +1,69 @@ |
3675 | +/* |
3676 | + * Copyright (C) 2013 Canonical Ltd |
3677 | + * |
3678 | + * This program is free software: you can redistribute it and/or modify |
3679 | + * it under the terms of the Lesser GNU General Public License version 3 as |
3680 | + * published by the Free Software Foundation. |
3681 | + * |
3682 | + * This program is distributed in the hope that it will be useful, |
3683 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
3684 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3685 | + * Lesser GNU General Public License for more details. |
3686 | + * |
3687 | + * You should have received a copy of the Lesser GNU General Public License |
3688 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
3689 | + * |
3690 | + * Authored by: Michi Henning <michi.henning@canonical.com> |
3691 | + */ |
3692 | + |
3693 | +#ifndef UNITY_API_SCOPES_INTERNAL_ICEMIDDLEWARE_ICEREGISTRYPROXY_H |
3694 | +#define UNITY_API_SCOPES_INTERNAL_ICEMIDDLEWARE_ICEREGISTRYPROXY_H |
3695 | + |
3696 | +#include <slice/unity/api/scopes/internal/ice_middleware/Registry.h> |
3697 | +#include <unity/api/scopes/internal/MWRegistryProxy.h> |
3698 | + |
3699 | +namespace unity |
3700 | +{ |
3701 | + |
3702 | +namespace api |
3703 | +{ |
3704 | + |
3705 | +namespace scopes |
3706 | +{ |
3707 | + |
3708 | +namespace internal |
3709 | +{ |
3710 | + |
3711 | +namespace ice_middleware |
3712 | +{ |
3713 | + |
3714 | +// Client-side registry proxy for Ice. The implementation forwards the invocations via Ice, |
3715 | +// and translates the parameters and return value between the Ice types and the public types. |
3716 | + |
3717 | +class IceRegistryProxy : public MWRegistryProxy |
3718 | +{ |
3719 | +public: |
3720 | + UNITY_DEFINES_PTRS(IceRegistryProxy); |
3721 | + |
3722 | + IceRegistryProxy(MiddlewareBase* mw_base, Ice::ObjectPrx const& p) noexcept; |
3723 | + ~IceRegistryProxy() noexcept; |
3724 | + |
3725 | + // Remote operations. |
3726 | + virtual ScopeProxy::SPtr find(std::string const& scope_name) override; |
3727 | + virtual ScopeMap list() override; |
3728 | + |
3729 | +private: |
3730 | + middleware::RegistryPrx proxy_; // Ice proxy for the registry |
3731 | +}; |
3732 | + |
3733 | +} // namespace ice_middleware |
3734 | + |
3735 | +} // namespace internal |
3736 | + |
3737 | +} // namespace scopes |
3738 | + |
3739 | +} // namespace api |
3740 | + |
3741 | +} // namespace unity |
3742 | + |
3743 | +#endif |
3744 | |
3745 | === added file 'include/unity/api/scopes/internal/ice_middleware/IceReplyProxy.h' |
3746 | --- include/unity/api/scopes/internal/ice_middleware/IceReplyProxy.h 1970-01-01 00:00:00 +0000 |
3747 | +++ include/unity/api/scopes/internal/ice_middleware/IceReplyProxy.h 2013-08-05 06:40:36 +0000 |
3748 | @@ -0,0 +1,67 @@ |
3749 | +/* |
3750 | + * Copyright (C) 2013 Canonical Ltd |
3751 | + * |
3752 | + * This program is free software: you can redistribute it and/or modify |
3753 | + * it under the terms of the Lesser GNU General Public License version 3 as |
3754 | + * published by the Free Software Foundation. |
3755 | + * |
3756 | + * This program is distributed in the hope that it will be useful, |
3757 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
3758 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3759 | + * Lesser GNU General Public License for more details. |
3760 | + * |
3761 | + * You should have received a copy of the Lesser GNU General Public License |
3762 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
3763 | + * |
3764 | + * Authored by: Michi Henning <michi.henning@canonical.com> |
3765 | + */ |
3766 | + |
3767 | +#ifndef UNITY_API_SCOPES_INTERNAL_ICEMIDDLEWARE_ICEREPLYPROXY_H |
3768 | +#define UNITY_API_SCOPES_INTERNAL_ICEMIDDLEWARE_ICEREPLYPROXY_H |
3769 | + |
3770 | +#include <slice/unity/api/scopes/internal/ice_middleware/Reply.h> |
3771 | +#include <unity/api/scopes/internal/MWReplyProxy.h> |
3772 | + |
3773 | +namespace unity |
3774 | +{ |
3775 | + |
3776 | +namespace api |
3777 | +{ |
3778 | + |
3779 | +namespace scopes |
3780 | +{ |
3781 | + |
3782 | +namespace internal |
3783 | +{ |
3784 | + |
3785 | +namespace ice_middleware |
3786 | +{ |
3787 | + |
3788 | +class IceReplyProxy : public MWReplyProxy |
3789 | +{ |
3790 | +public: |
3791 | + UNITY_DEFINES_PTRS(IceReplyProxy); |
3792 | + |
3793 | + IceReplyProxy(MiddlewareBase* mw_base, Ice::ObjectPrx const& p) noexcept; |
3794 | + ~IceReplyProxy() noexcept; |
3795 | + |
3796 | + virtual void send(std::string const& result) override; |
3797 | + virtual void finished() override; |
3798 | + |
3799 | + middleware::ReplyPrx proxy() const noexcept; |
3800 | + |
3801 | +private: |
3802 | + middleware::ReplyPrx proxy_; |
3803 | +}; |
3804 | + |
3805 | +} // namespace ice_middleware |
3806 | + |
3807 | +} // namespace internal |
3808 | + |
3809 | +} // namespace scopes |
3810 | + |
3811 | +} // namespace api |
3812 | + |
3813 | +} // namespace unity |
3814 | + |
3815 | +#endif |
3816 | |
3817 | === added file 'include/unity/api/scopes/internal/ice_middleware/IceScopeProxy.h' |
3818 | --- include/unity/api/scopes/internal/ice_middleware/IceScopeProxy.h 1970-01-01 00:00:00 +0000 |
3819 | +++ include/unity/api/scopes/internal/ice_middleware/IceScopeProxy.h 2013-08-05 06:40:36 +0000 |
3820 | @@ -0,0 +1,66 @@ |
3821 | +/* |
3822 | + * Copyright (C) 2013 Canonical Ltd |
3823 | + * |
3824 | + * This program is free software: you can redistribute it and/or modify |
3825 | + * it under the terms of the Lesser GNU General Public License version 3 as |
3826 | + * published by the Free Software Foundation. |
3827 | + * |
3828 | + * This program is distributed in the hope that it will be useful, |
3829 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
3830 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3831 | + * Lesser GNU General Public License for more details. |
3832 | + * |
3833 | + * You should have received a copy of the Lesser GNU General Public License |
3834 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
3835 | + * |
3836 | + * Authored by: Michi Henning <michi.henning@canonical.com> |
3837 | + */ |
3838 | + |
3839 | +#ifndef UNITY_API_SCOPES_INTERNAL_ICEMIDDLEWARE_ICESCOPEPROXY_H |
3840 | +#define UNITY_API_SCOPES_INTERNAL_ICEMIDDLEWARE_ICESCOPEPROXY_H |
3841 | + |
3842 | +#include <slice/unity/api/scopes/internal/ice_middleware/Scope.h> |
3843 | +#include <unity/api/scopes/internal/MWScopeProxy.h> |
3844 | + |
3845 | +namespace unity |
3846 | +{ |
3847 | + |
3848 | +namespace api |
3849 | +{ |
3850 | + |
3851 | +namespace scopes |
3852 | +{ |
3853 | + |
3854 | +namespace internal |
3855 | +{ |
3856 | + |
3857 | +namespace ice_middleware |
3858 | +{ |
3859 | + |
3860 | +class IceScopeProxy : public MWScopeProxy |
3861 | +{ |
3862 | +public: |
3863 | + UNITY_DEFINES_PTRS(IceScopeProxy); |
3864 | + |
3865 | + IceScopeProxy(MiddlewareBase* mw_base, Ice::ObjectPrx const& p) noexcept; |
3866 | + ~IceScopeProxy() noexcept; |
3867 | + |
3868 | + void query(std::string const& q, MWReplyProxy::SPtr const& reply) override; |
3869 | + |
3870 | + middleware::ScopePrx proxy() const noexcept; |
3871 | + |
3872 | +private: |
3873 | + middleware::ScopePrx proxy_; |
3874 | +}; |
3875 | + |
3876 | +} // namespace ice_middleware |
3877 | + |
3878 | +} // namespace internal |
3879 | + |
3880 | +} // namespace scopes |
3881 | + |
3882 | +} // namespace api |
3883 | + |
3884 | +} // namespace unity |
3885 | + |
3886 | +#endif |
3887 | |
3888 | === added file 'include/unity/api/scopes/internal/ice_middleware/RegistryI.h' |
3889 | --- include/unity/api/scopes/internal/ice_middleware/RegistryI.h 1970-01-01 00:00:00 +0000 |
3890 | +++ include/unity/api/scopes/internal/ice_middleware/RegistryI.h 2013-08-05 06:40:36 +0000 |
3891 | @@ -0,0 +1,72 @@ |
3892 | +/* |
3893 | + * Copyright (C) 2013 Canonical Ltd |
3894 | + * |
3895 | + * This program is free software: you can redistribute it and/or modify |
3896 | + * it under the terms of the GNU General Public License version 3 as |
3897 | + * published by the Free Software Foundation. |
3898 | + * |
3899 | + * This program is distributed in the hope that it will be useful, |
3900 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
3901 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3902 | + * GNU General Public License for more details. |
3903 | + * |
3904 | + * You should have received a copy of the GNU General Public License |
3905 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
3906 | + * |
3907 | + * Authored by: Michi Henning <michi.henning@canonical.com> |
3908 | + */ |
3909 | + |
3910 | +#ifndef UNITY_API_SCOPES_INTERNAL_ICEMIDDLEWARE_REGISTRYI_H |
3911 | +#define UNITY_API_SCOPES_INTERNAL_ICEMIDDLEWARE_REGISTRYI_H |
3912 | + |
3913 | +#include <slice/unity/api/scopes/internal/ice_middleware/Registry.h> |
3914 | +#include <unity/api/scopes/internal/RegistryObject.h> |
3915 | + |
3916 | +namespace unity |
3917 | +{ |
3918 | + |
3919 | +namespace api |
3920 | +{ |
3921 | + |
3922 | +namespace scopes |
3923 | +{ |
3924 | + |
3925 | +namespace internal |
3926 | +{ |
3927 | + |
3928 | +namespace ice_middleware |
3929 | +{ |
3930 | + |
3931 | +// Server-side implementation of a Registry object, which maps scope names to scope proxies. |
3932 | +// It provides remote lookup and listing of the map contents, and local methods to manipulate the map. |
3933 | +// |
3934 | +// This class is thread-safe: differnt threads can concurrently update the map while lookup operations |
3935 | +// are in progress. |
3936 | + |
3937 | +class RegistryI : public middleware::Registry |
3938 | +{ |
3939 | +public: |
3940 | + RegistryI(RegistryObject::SPtr const& ro); |
3941 | + virtual ~RegistryI() noexcept; |
3942 | + |
3943 | + // Slice operations |
3944 | + virtual middleware::ScopePrx find(std::string const& name, Ice::Current const&) override; |
3945 | + virtual middleware::ScopeDict list(Ice::Current const&) override; |
3946 | + |
3947 | +private: |
3948 | + RegistryObject::SPtr ro_; |
3949 | +}; |
3950 | + |
3951 | +typedef IceUtil::Handle<RegistryI> RegistryIPtr; |
3952 | + |
3953 | +} // namespace ice_middleware |
3954 | + |
3955 | +} // namespace internal |
3956 | + |
3957 | +} // namespace scopes |
3958 | + |
3959 | +} // namespace api |
3960 | + |
3961 | +} // namespace unity |
3962 | + |
3963 | +#endif |
3964 | |
3965 | === added file 'include/unity/api/scopes/internal/ice_middleware/ReplyI.h' |
3966 | --- include/unity/api/scopes/internal/ice_middleware/ReplyI.h 1970-01-01 00:00:00 +0000 |
3967 | +++ include/unity/api/scopes/internal/ice_middleware/ReplyI.h 2013-08-05 06:40:36 +0000 |
3968 | @@ -0,0 +1,67 @@ |
3969 | +/* |
3970 | + * Copyright (C) 2013 Canonical Ltd |
3971 | + * |
3972 | + * This program is free software: you can redistribute it and/or modify |
3973 | + * it under the terms of the GNU General Public License version 3 as |
3974 | + * published by the Free Software Foundation. |
3975 | + * |
3976 | + * This program is distributed in the hope that it will be useful, |
3977 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
3978 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3979 | + * GNU General Public License for more details. |
3980 | + * |
3981 | + * You should have received a copy of the GNU General Public License |
3982 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
3983 | + * |
3984 | + * Authored by: Michi Henning <michi.henning@canonical.com> |
3985 | + */ |
3986 | + |
3987 | +#ifndef UNITY_API_SCOPES_INTERNAL_ICEMIDDLEWARE_REPLYI_H |
3988 | +#define UNITY_API_SCOPES_INTERNAL_ICEMIDDLEWARE_REPLYI_H |
3989 | + |
3990 | +#include <slice/unity/api/scopes/internal/ice_middleware/Reply.h> |
3991 | +#include <unity/api/scopes/internal/ReplyObject.h> |
3992 | + |
3993 | +namespace unity |
3994 | +{ |
3995 | + |
3996 | +namespace api |
3997 | +{ |
3998 | + |
3999 | +namespace scopes |
4000 | +{ |
4001 | + |
4002 | +class ScopeBase; |
4003 | + |
4004 | +namespace internal |
4005 | +{ |
4006 | + |
4007 | +namespace ice_middleware |
4008 | +{ |
4009 | + |
4010 | +class ReplyI : public middleware::Reply |
4011 | +{ |
4012 | +public: |
4013 | + ReplyI(ReplyObject::SPtr const& ro); |
4014 | + |
4015 | + virtual void send(std::string const& result, Ice::Current const&) override; |
4016 | + virtual void finished(Ice::Current const&) override; |
4017 | + |
4018 | +private: |
4019 | + ReplyObject::SPtr ro_; |
4020 | + std::atomic_bool finished_; |
4021 | +}; |
4022 | + |
4023 | +typedef IceUtil::Handle<ReplyI> ReplyIPtr; |
4024 | + |
4025 | +} // namespace ice_middleware |
4026 | + |
4027 | +} // namespace internal |
4028 | + |
4029 | +} // namespace scopes |
4030 | + |
4031 | +} // namespace api |
4032 | + |
4033 | +} // namespace unity |
4034 | + |
4035 | +#endif |
4036 | |
4037 | === added file 'include/unity/api/scopes/internal/ice_middleware/RethrowException.h' |
4038 | --- include/unity/api/scopes/internal/ice_middleware/RethrowException.h 1970-01-01 00:00:00 +0000 |
4039 | +++ include/unity/api/scopes/internal/ice_middleware/RethrowException.h 2013-08-05 06:40:36 +0000 |
4040 | @@ -0,0 +1,55 @@ |
4041 | +/* |
4042 | + * Copyright (C) 2013 Canonical Ltd |
4043 | + * |
4044 | + * This program is free software: you can redistribute it and/or modify |
4045 | + * it under the terms of the GNU General Public License version 3 as |
4046 | + * published by the Free Software Foundation. |
4047 | + * |
4048 | + * This program is distributed in the hope that it will be useful, |
4049 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
4050 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4051 | + * GNU General Public License for more details. |
4052 | + * |
4053 | + * You should have received a copy of the GNU General Public License |
4054 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
4055 | + * |
4056 | + * Authored by: Michi Henning <michi.henning@canonical.com> |
4057 | + */ |
4058 | + |
4059 | +#ifndef UNITY_API_SCOPES_INTERNAL_ICEMIDDLEWARE_RETHROWEXCEPTION_H |
4060 | +#define UNITY_API_SCOPES_INTERNAL_ICEMIDDLEWARE_RETHROWEXCEPTION_H |
4061 | + |
4062 | +#include <Ice/Exception.h> |
4063 | + |
4064 | +namespace unity |
4065 | +{ |
4066 | + |
4067 | +namespace api |
4068 | +{ |
4069 | + |
4070 | +namespace scopes |
4071 | +{ |
4072 | + |
4073 | +class ScopeBase; |
4074 | + |
4075 | +namespace internal |
4076 | +{ |
4077 | + |
4078 | +namespace ice_middleware |
4079 | +{ |
4080 | + |
4081 | +// Convert an Ice exception to a unity::MiddlewareException and throw it. |
4082 | + |
4083 | +void rethrow_ice_ex(Ice::Exception const& e); |
4084 | + |
4085 | +} // namespace ice_middleware |
4086 | + |
4087 | +} // namespace internal |
4088 | + |
4089 | +} // namespace scopes |
4090 | + |
4091 | +} // namespace api |
4092 | + |
4093 | +} // namespace unity |
4094 | + |
4095 | +#endif |
4096 | |
4097 | === added file 'include/unity/api/scopes/internal/ice_middleware/ScopeI.h' |
4098 | --- include/unity/api/scopes/internal/ice_middleware/ScopeI.h 1970-01-01 00:00:00 +0000 |
4099 | +++ include/unity/api/scopes/internal/ice_middleware/ScopeI.h 2013-08-05 06:40:36 +0000 |
4100 | @@ -0,0 +1,70 @@ |
4101 | +/* |
4102 | + * Copyright (C) 2013 Canonical Ltd |
4103 | + * |
4104 | + * This program is free software: you can redistribute it and/or modify |
4105 | + * it under the terms of the GNU General Public License version 3 as |
4106 | + * published by the Free Software Foundation. |
4107 | + * |
4108 | + * This program is distributed in the hope that it will be useful, |
4109 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
4110 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4111 | + * GNU General Public License for more details. |
4112 | + * |
4113 | + * You should have received a copy of the GNU General Public License |
4114 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
4115 | + * |
4116 | + * Authored by: Michi Henning <michi.henning@canonical.com> |
4117 | + */ |
4118 | + |
4119 | +#ifndef UNITY_API_SCOPES_INTERNAL_ICEMIDDLEWARE_SCOPEI_H |
4120 | +#define UNITY_API_SCOPES_INTERNAL_ICEMIDDLEWARE_SCOPEI_H |
4121 | + |
4122 | +#include <slice/unity/api/scopes/internal/ice_middleware/Scope.h> |
4123 | +#include <unity/api/scopes/internal/ScopeObject.h> |
4124 | + |
4125 | +namespace unity |
4126 | +{ |
4127 | + |
4128 | +namespace api |
4129 | +{ |
4130 | + |
4131 | +namespace scopes |
4132 | +{ |
4133 | + |
4134 | +namespace internal |
4135 | +{ |
4136 | + |
4137 | +class MiddlewareBase; |
4138 | + |
4139 | +namespace ice_middleware |
4140 | +{ |
4141 | + |
4142 | +// Server-side implementation of a scope object. |
4143 | + |
4144 | +class ScopeI : public middleware::Scope |
4145 | +{ |
4146 | +public: |
4147 | + ScopeI(MiddlewareBase* mw_base, ScopeObject::SPtr const& ro); |
4148 | + virtual ~ScopeI() noexcept; |
4149 | + |
4150 | + // Slice operations |
4151 | + virtual void query(std::string const& q, middleware::ReplyPrx const& r, Ice::Current const&) override; |
4152 | + |
4153 | +private: |
4154 | + MiddlewareBase* mw_base_; |
4155 | + ScopeObject::SPtr so_; |
4156 | +}; |
4157 | + |
4158 | +typedef IceUtil::Handle<ScopeI> ScopeIPtr; |
4159 | + |
4160 | +} // namespace ice_middleware |
4161 | + |
4162 | +} // namespace internal |
4163 | + |
4164 | +} // namespace scopes |
4165 | + |
4166 | +} // namespace api |
4167 | + |
4168 | +} // namespace unity |
4169 | + |
4170 | +#endif |
4171 | |
4172 | === added directory 'include/unity/internal' |
4173 | === removed directory 'include/unity/internal' |
4174 | === added directory 'slice' |
4175 | === added file 'slice/CMakeLists.txt' |
4176 | --- slice/CMakeLists.txt 1970-01-01 00:00:00 +0000 |
4177 | +++ slice/CMakeLists.txt 2013-08-05 06:40:36 +0000 |
4178 | @@ -0,0 +1,4 @@ |
4179 | +add_subdirectory(unity) |
4180 | + |
4181 | +file(GLOB sf "${CMAKE_CURRENT_SOURCE_DIR}/*.ice") |
4182 | +set(SLICE_FILES ${SLICE_FILES} ${sf} PARENT_SCOPE) |
4183 | |
4184 | === added directory 'slice/unity' |
4185 | === added file 'slice/unity/CMakeLists.txt' |
4186 | --- slice/unity/CMakeLists.txt 1970-01-01 00:00:00 +0000 |
4187 | +++ slice/unity/CMakeLists.txt 2013-08-05 06:40:36 +0000 |
4188 | @@ -0,0 +1,4 @@ |
4189 | +add_subdirectory(api) |
4190 | + |
4191 | +file(GLOB sf "${CMAKE_CURRENT_SOURCE_DIR}/*.ice") |
4192 | +set(SLICE_FILES ${SLICE_FILES} ${sf} PARENT_SCOPE) |
4193 | |
4194 | === added directory 'slice/unity/api' |
4195 | === added file 'slice/unity/api/CMakeLists.txt' |
4196 | --- slice/unity/api/CMakeLists.txt 1970-01-01 00:00:00 +0000 |
4197 | +++ slice/unity/api/CMakeLists.txt 2013-08-05 06:40:36 +0000 |
4198 | @@ -0,0 +1,4 @@ |
4199 | +add_subdirectory(scopes) |
4200 | + |
4201 | +file(GLOB sf "${CMAKE_CURRENT_SOURCE_DIR}/*.ice") |
4202 | +set(SLICE_FILES ${SLICE_FILES} ${sf} PARENT_SCOPE) |
4203 | |
4204 | === added directory 'slice/unity/api/scopes' |
4205 | === added file 'slice/unity/api/scopes/CMakeLists.txt' |
4206 | --- slice/unity/api/scopes/CMakeLists.txt 1970-01-01 00:00:00 +0000 |
4207 | +++ slice/unity/api/scopes/CMakeLists.txt 2013-08-05 06:40:36 +0000 |
4208 | @@ -0,0 +1,4 @@ |
4209 | +add_subdirectory(internal) |
4210 | + |
4211 | +file(GLOB sf "${CMAKE_CURRENT_SOURCE_DIR}/*.ice") |
4212 | +set(SLICE_FILES ${SLICE_FILES} ${sf} PARENT_SCOPE) |
4213 | |
4214 | === added directory 'slice/unity/api/scopes/internal' |
4215 | === added file 'slice/unity/api/scopes/internal/CMakeLists.txt' |
4216 | --- slice/unity/api/scopes/internal/CMakeLists.txt 1970-01-01 00:00:00 +0000 |
4217 | +++ slice/unity/api/scopes/internal/CMakeLists.txt 2013-08-05 06:40:36 +0000 |
4218 | @@ -0,0 +1,4 @@ |
4219 | +add_subdirectory(ice_middleware) |
4220 | + |
4221 | +file(GLOB sf "${CMAKE_CURRENT_SOURCE_DIR}/*.ice") |
4222 | +set(SLICE_FILES ${SLICE_FILES} ${sf} PARENT_SCOPE) |
4223 | |
4224 | === added directory 'slice/unity/api/scopes/internal/ice_middleware' |
4225 | === added file 'slice/unity/api/scopes/internal/ice_middleware/CMakeLists.txt' |
4226 | --- slice/unity/api/scopes/internal/ice_middleware/CMakeLists.txt 1970-01-01 00:00:00 +0000 |
4227 | +++ slice/unity/api/scopes/internal/ice_middleware/CMakeLists.txt 2013-08-05 06:40:36 +0000 |
4228 | @@ -0,0 +1,2 @@ |
4229 | +file(GLOB sf "${CMAKE_CURRENT_SOURCE_DIR}/*.ice") |
4230 | +set(SLICE_FILES ${SLICE_FILES} ${sf} PARENT_SCOPE) |
4231 | |
4232 | === added file 'slice/unity/api/scopes/internal/ice_middleware/Registry.ice' |
4233 | --- slice/unity/api/scopes/internal/ice_middleware/Registry.ice 1970-01-01 00:00:00 +0000 |
4234 | +++ slice/unity/api/scopes/internal/ice_middleware/Registry.ice 2013-08-05 06:40:36 +0000 |
4235 | @@ -0,0 +1,52 @@ |
4236 | +/* |
4237 | + * Copyright (C) 2013 Canonical Ltd |
4238 | + * |
4239 | + * This program is free software: you can redistribute it and/or modify |
4240 | + * it under the terms of the GNU General Public License version 3 as |
4241 | + * published by the Free Software Foundation. |
4242 | + * |
4243 | + * This program is distributed in the hope that it will be useful, |
4244 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
4245 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4246 | + * GNU General Public License for more details. |
4247 | + * |
4248 | + * You should have received a copy of the GNU General Public License |
4249 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
4250 | + * |
4251 | + * Authored by: Michi Henning <michi.henning@canonical.com> |
4252 | + */ |
4253 | + |
4254 | +module unity |
4255 | +{ |
4256 | + |
4257 | +module api |
4258 | +{ |
4259 | + |
4260 | +module scopes |
4261 | +{ |
4262 | + |
4263 | +module internal |
4264 | +{ |
4265 | + |
4266 | +module middleware |
4267 | +{ |
4268 | + |
4269 | +interface Scope; |
4270 | + |
4271 | +dictionary<string, Scope*> ScopeDict; |
4272 | + |
4273 | +interface Registry |
4274 | +{ |
4275 | + Scope* find(string name); |
4276 | + ScopeDict list(); |
4277 | +}; |
4278 | + |
4279 | +}; // ice_middleware |
4280 | + |
4281 | +}; // internal |
4282 | + |
4283 | +}; // scopes |
4284 | + |
4285 | +}; // api |
4286 | + |
4287 | +}; // unity |
4288 | |
4289 | === added file 'slice/unity/api/scopes/internal/ice_middleware/Reply.ice' |
4290 | --- slice/unity/api/scopes/internal/ice_middleware/Reply.ice 1970-01-01 00:00:00 +0000 |
4291 | +++ slice/unity/api/scopes/internal/ice_middleware/Reply.ice 2013-08-05 06:40:36 +0000 |
4292 | @@ -0,0 +1,48 @@ |
4293 | +/* |
4294 | + * Copyright (C) 2013 Canonical Ltd |
4295 | + * |
4296 | + * This program is free software: you can redistribute it and/or modify |
4297 | + * it under the terms of the GNU General Public License version 3 as |
4298 | + * published by the Free Software Foundation. |
4299 | + * |
4300 | + * This program is distributed in the hope that it will be useful, |
4301 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
4302 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4303 | + * GNU General Public License for more details. |
4304 | + * |
4305 | + * You should have received a copy of the GNU General Public License |
4306 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
4307 | + * |
4308 | + * Authored by: Michi Henning <michi.henning@canonical.com> |
4309 | + */ |
4310 | + |
4311 | +module unity |
4312 | +{ |
4313 | + |
4314 | +module api |
4315 | +{ |
4316 | + |
4317 | +module scopes |
4318 | +{ |
4319 | + |
4320 | +module internal |
4321 | +{ |
4322 | + |
4323 | +module middleware |
4324 | +{ |
4325 | + |
4326 | +interface Reply |
4327 | +{ |
4328 | + void send(string result); |
4329 | + void finished(); |
4330 | +}; |
4331 | + |
4332 | +}; // ice_middleware |
4333 | + |
4334 | +}; // internal |
4335 | + |
4336 | +}; // scopes |
4337 | + |
4338 | +}; // api |
4339 | + |
4340 | +}; // unity |
4341 | |
4342 | === added file 'slice/unity/api/scopes/internal/ice_middleware/Scope.ice' |
4343 | --- slice/unity/api/scopes/internal/ice_middleware/Scope.ice 1970-01-01 00:00:00 +0000 |
4344 | +++ slice/unity/api/scopes/internal/ice_middleware/Scope.ice 2013-08-05 06:40:36 +0000 |
4345 | @@ -0,0 +1,49 @@ |
4346 | +/* |
4347 | + * Copyright (C) 2013 Canonical Ltd |
4348 | + * |
4349 | + * This program is free software: you can redistribute it and/or modify |
4350 | + * it under the terms of the GNU General Public License version 3 as |
4351 | + * published by the Free Software Foundation. |
4352 | + * |
4353 | + * This program is distributed in the hope that it will be useful, |
4354 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
4355 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4356 | + * GNU General Public License for more details. |
4357 | + * |
4358 | + * You should have received a copy of the GNU General Public License |
4359 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
4360 | + * |
4361 | + * Authored by: Michi Henning <michi.henning@canonical.com> |
4362 | + */ |
4363 | + |
4364 | +module unity |
4365 | +{ |
4366 | + |
4367 | +module api |
4368 | +{ |
4369 | + |
4370 | +module scopes |
4371 | +{ |
4372 | + |
4373 | +module internal |
4374 | +{ |
4375 | + |
4376 | +module middleware |
4377 | +{ |
4378 | + |
4379 | +interface Reply; |
4380 | + |
4381 | +interface Scope |
4382 | +{ |
4383 | + void query(string q, Reply* r); |
4384 | +}; |
4385 | + |
4386 | +}; // ice_middleware |
4387 | + |
4388 | +}; // internal |
4389 | + |
4390 | +}; // scopes |
4391 | + |
4392 | +}; // api |
4393 | + |
4394 | +}; // unity |
4395 | |
4396 | === modified file 'src/CMakeLists.txt' |
4397 | --- src/CMakeLists.txt 2013-06-25 01:19:40 +0000 |
4398 | +++ src/CMakeLists.txt 2013-08-05 06:40:36 +0000 |
4399 | @@ -1,31 +1,5 @@ |
4400 | add_subdirectory(unity) |
4401 | |
4402 | -# Pseudo-library of object files. We need a dynamic version of the library for normal clients, |
4403 | -# and a static version for the whitebox tests, so we can write unit tests for classes in the internal namespaces |
4404 | -# (because, for the .so, non-public APIs are compiled with -fvisibility=hidden). |
4405 | -# Everything is compiled with -fPIC, so the same object files are suitable for either library. |
4406 | -# Here, we create an object library that then is used to link the static and dynamic |
4407 | -# libraries, without having to compile each source file twice with different compile flags. |
4408 | - |
4409 | -set(UNITY_SCOPES_LIB_OBJ ${UNITY_SCOPES_LIB}-obj) |
4410 | -add_library(${UNITY_SCOPES_LIB_OBJ} OBJECT ${UNITY_SCOPES_LIB_SRC}) |
4411 | -set_target_properties(${UNITY_SCOPES_LIB_OBJ} PROPERTIES COMPILE_FLAGS "-fPIC") |
4412 | - |
4413 | -# Use the object files to make the shared library. |
4414 | -set(UNITY_SCOPES_SOVERSION 0) |
4415 | -add_library(${UNITY_SCOPES_LIB} SHARED $<TARGET_OBJECTS:${UNITY_SCOPES_LIB_OBJ}>) |
4416 | -set_target_properties(${UNITY_SCOPES_LIB} PROPERTIES |
4417 | - VERSION "${UNITY_SCOPES_MAJOR}.${UNITY_SCOPES_MINOR}" |
4418 | - SOVERSION ${UNITY_SCOPES_SOVERSION} |
4419 | -) |
4420 | - |
4421 | -# Use the object files to make the static library. |
4422 | -add_library(${UNITY_SCOPES_STATIC_LIB} STATIC $<TARGET_OBJECTS:${UNITY_SCOPES_LIB_OBJ}>) |
4423 | -set_target_properties(${UNITY_SCOPES_STATIC_LIB} PROPERTIES OUTPUT_NAME ${UNITY_SCOPES_LIB}) |
4424 | - |
4425 | -# Only the dynamic library gets installed. |
4426 | -install(TARGETS ${UNITY_SCOPES_LIB} LIBRARY DESTINATION ${LIB_INSTALL_PREFIX}) |
4427 | - |
4428 | # Set up package config. |
4429 | configure_file(lib${UNITY_SCOPES_LIB}.pc.in lib${UNITY_SCOPES_LIB}.pc @ONLY) |
4430 | install(FILES ${CMAKE_CURRENT_BINARY_DIR}/lib${UNITY_SCOPES_LIB}.pc DESTINATION ${LIB_INSTALL_PREFIX}/pkgconfig) |
4431 | |
4432 | === modified file 'src/unity/api/scopes/CMakeLists.txt' |
4433 | --- src/unity/api/scopes/CMakeLists.txt 2013-06-18 09:02:02 +0000 |
4434 | +++ src/unity/api/scopes/CMakeLists.txt 2013-08-05 06:40:36 +0000 |
4435 | @@ -1,8 +1,14 @@ |
4436 | add_subdirectory(internal) |
4437 | |
4438 | set(SRC |
4439 | + ${CMAKE_CURRENT_SOURCE_DIR}/ObjectProxy.cpp |
4440 | + ${CMAKE_CURRENT_SOURCE_DIR}/RegistryProxy.cpp |
4441 | + ${CMAKE_CURRENT_SOURCE_DIR}/ReplyBase.cpp |
4442 | + ${CMAKE_CURRENT_SOURCE_DIR}/ReplyProxy.cpp |
4443 | + ${CMAKE_CURRENT_SOURCE_DIR}/Runtime.cpp |
4444 | ${CMAKE_CURRENT_SOURCE_DIR}/ScopeBase.cpp |
4445 | ${CMAKE_CURRENT_SOURCE_DIR}/ScopeExceptions.cpp |
4446 | + ${CMAKE_CURRENT_SOURCE_DIR}/ScopeProxy.cpp |
4447 | ${CMAKE_CURRENT_SOURCE_DIR}/Version.cpp |
4448 | ) |
4449 | |
4450 | |
4451 | === added file 'src/unity/api/scopes/ObjectProxy.cpp' |
4452 | --- src/unity/api/scopes/ObjectProxy.cpp 1970-01-01 00:00:00 +0000 |
4453 | +++ src/unity/api/scopes/ObjectProxy.cpp 2013-08-05 06:40:36 +0000 |
4454 | @@ -0,0 +1,46 @@ |
4455 | +/* |
4456 | + * Copyright (C) 2013 Canonical Ltd |
4457 | + * |
4458 | + * This program is free software: you can redistribute it and/or modify |
4459 | + * it under the terms of the Lesser GNU General Public License version 3 as |
4460 | + * published by the Free Software Foundation. |
4461 | + * |
4462 | + * This program is distributed in the hope that it will be useful, |
4463 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
4464 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4465 | + * Lesser GNU General Public License for more details. |
4466 | + * |
4467 | + * You should have received a copy of the Lesser GNU General Public License |
4468 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
4469 | + * |
4470 | + * Authored by: Michi Henning <michi.henning@canonical.com> |
4471 | + */ |
4472 | + |
4473 | +#include <unity/api/scopes/ObjectProxy.h> |
4474 | + |
4475 | +namespace unity |
4476 | +{ |
4477 | + |
4478 | +namespace api |
4479 | +{ |
4480 | + |
4481 | +namespace scopes |
4482 | +{ |
4483 | + |
4484 | +//! @cond |
4485 | + |
4486 | +ObjectProxy::ObjectProxy() |
4487 | +{ |
4488 | +} |
4489 | + |
4490 | +ObjectProxy::~ObjectProxy() noexcept |
4491 | +{ |
4492 | +} |
4493 | + |
4494 | +//! @endcond |
4495 | + |
4496 | +} // namespace scopes |
4497 | + |
4498 | +} // namespace api |
4499 | + |
4500 | +} // namespace unity |
4501 | |
4502 | === added file 'src/unity/api/scopes/RegistryProxy.cpp' |
4503 | --- src/unity/api/scopes/RegistryProxy.cpp 1970-01-01 00:00:00 +0000 |
4504 | +++ src/unity/api/scopes/RegistryProxy.cpp 2013-08-05 06:40:36 +0000 |
4505 | @@ -0,0 +1,58 @@ |
4506 | +/* |
4507 | + * Copyright (C) 2013 Canonical Ltd |
4508 | + * |
4509 | + * This program is free software: you can redistribute it and/or modify |
4510 | + * it under the terms of the Lesser GNU General Public License version 3 as |
4511 | + * published by the Free Software Foundation. |
4512 | + * |
4513 | + * This program is distributed in the hope that it will be useful, |
4514 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
4515 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4516 | + * Lesser GNU General Public License for more details. |
4517 | + * |
4518 | + * You should have received a copy of the Lesser GNU General Public License |
4519 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
4520 | + * |
4521 | + * Authored by: Michi Henning <michi.henning@canonical.com> |
4522 | + */ |
4523 | + |
4524 | +#include <unity/api/scopes/RegistryProxy.h> |
4525 | +#include <unity/api/scopes/internal/RegistryProxyImpl.h> |
4526 | + |
4527 | +namespace unity |
4528 | +{ |
4529 | + |
4530 | +namespace api |
4531 | +{ |
4532 | + |
4533 | +namespace scopes |
4534 | +{ |
4535 | + |
4536 | +//! @cond |
4537 | + |
4538 | +RegistryProxy::RegistryProxy(internal::RegistryProxyImpl* impl) : |
4539 | + p(impl) |
4540 | +{ |
4541 | +} |
4542 | + |
4543 | +RegistryProxy::~RegistryProxy() noexcept |
4544 | +{ |
4545 | +} |
4546 | + |
4547 | +//! @endcond |
4548 | + |
4549 | +ScopeProxy::SPtr RegistryProxy::find(std::string const& scope_name) const |
4550 | +{ |
4551 | + return p->find(scope_name); |
4552 | +} |
4553 | + |
4554 | +ScopeMap RegistryProxy::list() const |
4555 | +{ |
4556 | + return p->list(); |
4557 | +} |
4558 | + |
4559 | +} // namespace scopes |
4560 | + |
4561 | +} // namespace api |
4562 | + |
4563 | +} // namespace unity |
4564 | |
4565 | === added file 'src/unity/api/scopes/ReplyBase.cpp' |
4566 | --- src/unity/api/scopes/ReplyBase.cpp 1970-01-01 00:00:00 +0000 |
4567 | +++ src/unity/api/scopes/ReplyBase.cpp 2013-08-05 06:40:36 +0000 |
4568 | @@ -0,0 +1,48 @@ |
4569 | +/* |
4570 | + * Copyright (C) 2013 Canonical Ltd |
4571 | + * |
4572 | + * This program is free software: you can redistribute it and/or modify |
4573 | + * it under the terms of the Lesser GNU General Public License version 3 as |
4574 | + * published by the Free Software Foundation. |
4575 | + * |
4576 | + * This program is distributed in the hope that it will be useful, |
4577 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
4578 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4579 | + * Lesser GNU General Public License for more details. |
4580 | + * |
4581 | + * You should have received a copy of the Lesser GNU General Public License |
4582 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
4583 | + * |
4584 | + * Authored by: Michi Henning <michi.henning@canonical.com> |
4585 | + */ |
4586 | + |
4587 | +#include <unity/api/scopes/ReplyBase.h> |
4588 | + |
4589 | +using namespace std; |
4590 | + |
4591 | +namespace unity |
4592 | +{ |
4593 | + |
4594 | +namespace api |
4595 | +{ |
4596 | + |
4597 | +namespace scopes |
4598 | +{ |
4599 | + |
4600 | +//! @cond |
4601 | + |
4602 | +ReplyBase::ReplyBase() |
4603 | +{ |
4604 | +} |
4605 | + |
4606 | +ReplyBase::~ReplyBase() noexcept |
4607 | +{ |
4608 | +} |
4609 | + |
4610 | +//! @endcond |
4611 | + |
4612 | +} // namespace scopes |
4613 | + |
4614 | +} // namespace api |
4615 | + |
4616 | +} // namespace unity |
4617 | |
4618 | === added file 'src/unity/api/scopes/ReplyProxy.cpp' |
4619 | --- src/unity/api/scopes/ReplyProxy.cpp 1970-01-01 00:00:00 +0000 |
4620 | +++ src/unity/api/scopes/ReplyProxy.cpp 2013-08-05 06:40:36 +0000 |
4621 | @@ -0,0 +1,59 @@ |
4622 | +/* |
4623 | + * Copyright (C) 2013 Canonical Ltd |
4624 | + * |
4625 | + * This program is free software: you can redistribute it and/or modify |
4626 | + * it under the terms of the Lesser GNU General Public License version 3 as |
4627 | + * published by the Free Software Foundation. |
4628 | + * |
4629 | + * This program is distributed in the hope that it will be useful, |
4630 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
4631 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4632 | + * Lesser GNU General Public License for more details. |
4633 | + * |
4634 | + * You should have received a copy of the Lesser GNU General Public License |
4635 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
4636 | + * |
4637 | + * Authored by: Michi Henning <michi.henning@canonical.com> |
4638 | + */ |
4639 | + |
4640 | +#include <unity/api/scopes/ReplyProxy.h> |
4641 | + |
4642 | +#include <unity/api/scopes/internal/ReplyProxyImpl.h> |
4643 | + |
4644 | +namespace unity |
4645 | +{ |
4646 | + |
4647 | +namespace api |
4648 | +{ |
4649 | + |
4650 | +namespace scopes |
4651 | +{ |
4652 | + |
4653 | +//! @cond |
4654 | + |
4655 | +ReplyProxy::ReplyProxy(internal::ReplyProxyImpl* impl) |
4656 | + : p(impl) |
4657 | +{ |
4658 | +} |
4659 | + |
4660 | +ReplyProxy::~ReplyProxy() noexcept |
4661 | +{ |
4662 | +} |
4663 | + |
4664 | +void ReplyProxy::send(std::string const& result) |
4665 | +{ |
4666 | + return p->send(result); |
4667 | +} |
4668 | + |
4669 | +void ReplyProxy::finished() |
4670 | +{ |
4671 | + return p->finished(); |
4672 | +} |
4673 | + |
4674 | +//! @endcond |
4675 | + |
4676 | +} // namespace scopes |
4677 | + |
4678 | +} // namespace api |
4679 | + |
4680 | +} // namespace unity |
4681 | |
4682 | === added file 'src/unity/api/scopes/Runtime.cpp' |
4683 | --- src/unity/api/scopes/Runtime.cpp 1970-01-01 00:00:00 +0000 |
4684 | +++ src/unity/api/scopes/Runtime.cpp 2013-08-05 06:40:36 +0000 |
4685 | @@ -0,0 +1,68 @@ |
4686 | +/* |
4687 | + * Copyright (C) 2013 Canonical Ltd |
4688 | + * |
4689 | + * This program is free software: you can redistribute it and/or modify |
4690 | + * it under the terms of the Lesser GNU General Public License version 3 as |
4691 | + * published by the Free Software Foundation. |
4692 | + * |
4693 | + * This program is distributed in the hope that it will be useful, |
4694 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
4695 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4696 | + * Lesser GNU General Public License for more details. |
4697 | + * |
4698 | + * You should have received a copy of the Lesser GNU General Public License |
4699 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
4700 | + * |
4701 | + * Authored by: Michi Henning <michi.henning@canonical.com> |
4702 | + */ |
4703 | + |
4704 | +#include <unity/api/scopes/Runtime.h> |
4705 | + |
4706 | +#include <unity/api/scopes/internal/RuntimeImpl.h> |
4707 | + |
4708 | +using namespace std; |
4709 | + |
4710 | +namespace unity |
4711 | +{ |
4712 | + |
4713 | +namespace api |
4714 | +{ |
4715 | + |
4716 | +namespace scopes |
4717 | +{ |
4718 | + |
4719 | +constexpr char const* Runtime::DFLT_CONFIGFILE; |
4720 | + |
4721 | +//! @cond |
4722 | + |
4723 | +Runtime::Runtime(string const& scope_name, string const& configfile) : |
4724 | + p(internal::RuntimeImpl::create(scope_name, configfile)) |
4725 | +{ |
4726 | +} |
4727 | + |
4728 | +Runtime::~Runtime() noexcept |
4729 | +{ |
4730 | +} |
4731 | + |
4732 | +//! @endcond |
4733 | + |
4734 | +Runtime::UPtr Runtime::create(string const& scope_name, string const& configfile) |
4735 | +{ |
4736 | + return UPtr(new Runtime(scope_name, configfile)); |
4737 | +} |
4738 | + |
4739 | +void Runtime::destroy() |
4740 | +{ |
4741 | + p->destroy(); |
4742 | +} |
4743 | + |
4744 | +RegistryProxy::SPtr Runtime::registry() const |
4745 | +{ |
4746 | + return p->registry(); |
4747 | +} |
4748 | + |
4749 | +} // namespace scopes |
4750 | + |
4751 | +} // namespace api |
4752 | + |
4753 | +} // namespace unity |
4754 | |
4755 | === modified file 'src/unity/api/scopes/ScopeBase.cpp' |
4756 | --- src/unity/api/scopes/ScopeBase.cpp 2013-07-04 00:39:02 +0000 |
4757 | +++ src/unity/api/scopes/ScopeBase.cpp 2013-08-05 06:40:36 +0000 |
4758 | @@ -27,9 +27,19 @@ |
4759 | namespace scopes |
4760 | { |
4761 | |
4762 | -void |
4763 | -ScopeBase:: |
4764 | -runtime_version(int& v_major, int& v_minor, int& v_micro) noexcept |
4765 | +//! @cond |
4766 | + |
4767 | +ScopeBase::ScopeBase() |
4768 | +{ |
4769 | +} |
4770 | + |
4771 | +ScopeBase::~ScopeBase() |
4772 | +{ |
4773 | +} |
4774 | + |
4775 | +//! @endcond |
4776 | + |
4777 | +void ScopeBase::runtime_version(int& v_major, int& v_minor, int& v_micro) noexcept |
4778 | { |
4779 | v_major = unity::api::scopes::major_version(); |
4780 | v_minor = unity::api::scopes::minor_version(); |
4781 | |
4782 | === modified file 'src/unity/api/scopes/ScopeExceptions.cpp' |
4783 | --- src/unity/api/scopes/ScopeExceptions.cpp 2013-06-25 01:19:40 +0000 |
4784 | +++ src/unity/api/scopes/ScopeExceptions.cpp 2013-08-05 06:40:36 +0000 |
4785 | @@ -56,7 +56,7 @@ |
4786 | MiddlewareException:: |
4787 | what() const noexcept |
4788 | { |
4789 | - return "unity::api::scopes::MiddleWareException"; |
4790 | + return "unity::api::scopes::MiddlewareException"; |
4791 | } |
4792 | |
4793 | exception_ptr |
4794 | @@ -66,6 +66,41 @@ |
4795 | return make_exception_ptr(*this); |
4796 | } |
4797 | |
4798 | +ConfigException:: |
4799 | +ConfigException(string const& reason) |
4800 | + : Exception(make_shared<unity::ExceptionImplBase>(this, reason)) |
4801 | +{ |
4802 | +} |
4803 | + |
4804 | +ConfigException:: |
4805 | +ConfigException(ConfigException const&) = default; |
4806 | + |
4807 | +//! @cond |
4808 | + |
4809 | +ConfigException& |
4810 | +ConfigException:: |
4811 | +operator=(ConfigException const&) = default; |
4812 | + |
4813 | + |
4814 | +ConfigException:: |
4815 | +~ConfigException() noexcept = default; |
4816 | + |
4817 | +//! @endcond |
4818 | + |
4819 | +char const* |
4820 | +ConfigException:: |
4821 | +what() const noexcept |
4822 | +{ |
4823 | + return "unity::api::scopes::ConfigException"; |
4824 | +} |
4825 | + |
4826 | +exception_ptr |
4827 | +ConfigException:: |
4828 | +self() const |
4829 | +{ |
4830 | + return make_exception_ptr(*this); |
4831 | +} |
4832 | + |
4833 | } // namespace scopes |
4834 | |
4835 | } // namespace api |
4836 | |
4837 | === added file 'src/unity/api/scopes/ScopeProxy.cpp' |
4838 | --- src/unity/api/scopes/ScopeProxy.cpp 1970-01-01 00:00:00 +0000 |
4839 | +++ src/unity/api/scopes/ScopeProxy.cpp 2013-08-05 06:40:36 +0000 |
4840 | @@ -0,0 +1,54 @@ |
4841 | +/* |
4842 | + * Copyright (C) 2013 Canonical Ltd |
4843 | + * |
4844 | + * This program is free software: you can redistribute it and/or modify |
4845 | + * it under the terms of the Lesser GNU General Public License version 3 as |
4846 | + * published by the Free Software Foundation. |
4847 | + * |
4848 | + * This program is distributed in the hope that it will be useful, |
4849 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
4850 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4851 | + * Lesser GNU General Public License for more details. |
4852 | + * |
4853 | + * You should have received a copy of the Lesser GNU General Public License |
4854 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
4855 | + * |
4856 | + * Authored by: Michi Henning <michi.henning@canonical.com> |
4857 | + */ |
4858 | + |
4859 | +#include <unity/api/scopes/ScopeProxy.h> |
4860 | + |
4861 | +#include <unity/api/scopes/internal/ScopeProxyImpl.h> |
4862 | + |
4863 | +namespace unity |
4864 | +{ |
4865 | + |
4866 | +namespace api |
4867 | +{ |
4868 | + |
4869 | +namespace scopes |
4870 | +{ |
4871 | + |
4872 | +//! @cond |
4873 | + |
4874 | +ScopeProxy::ScopeProxy(internal::ScopeProxyImpl* impl) : |
4875 | + p(impl) |
4876 | +{ |
4877 | +} |
4878 | + |
4879 | +ScopeProxy::~ScopeProxy() noexcept |
4880 | +{ |
4881 | +} |
4882 | + |
4883 | +void ScopeProxy::query(std::string const& q, ReplyBase::SPtr const& reply) |
4884 | +{ |
4885 | + p->query(q, reply); |
4886 | +} |
4887 | + |
4888 | +//! @endcond |
4889 | + |
4890 | +} // namespace scopes |
4891 | + |
4892 | +} // namespace api |
4893 | + |
4894 | +} // namespace unity |
4895 | |
4896 | === modified file 'src/unity/api/scopes/Version.cpp' |
4897 | --- src/unity/api/scopes/Version.cpp 2013-07-02 00:58:04 +0000 |
4898 | +++ src/unity/api/scopes/Version.cpp 2013-08-05 06:40:36 +0000 |
4899 | @@ -44,7 +44,8 @@ |
4900 | return UNITY_SCOPES_VERSION_MICRO; |
4901 | } |
4902 | |
4903 | -char const* str() |
4904 | +char const* |
4905 | +version_string() |
4906 | { |
4907 | return UNITY_SCOPES_VERSION_STRING; |
4908 | } |
4909 | |
4910 | === added file 'src/unity/api/scopes/internal/AbstractObject.cpp' |
4911 | --- src/unity/api/scopes/internal/AbstractObject.cpp 1970-01-01 00:00:00 +0000 |
4912 | +++ src/unity/api/scopes/internal/AbstractObject.cpp 2013-08-05 06:40:36 +0000 |
4913 | @@ -0,0 +1,47 @@ |
4914 | +/* |
4915 | + * Copyright (C) 2013 Canonical Ltd |
4916 | + * |
4917 | + * This program is free software: you can redistribute it and/or modify |
4918 | + * it under the terms of the Lesser GNU General Public License version 3 as |
4919 | + * published by the Free Software Foundation. |
4920 | + * |
4921 | + * This program is distributed in the hope that it will be useful, |
4922 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
4923 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4924 | + * Lesser GNU General Public License for more details. |
4925 | + * |
4926 | + * You should have received a copy of the Lesser GNU General Public License |
4927 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
4928 | + * |
4929 | + * Authored by: Michi Henning <michi.henning@canonical.com> |
4930 | + */ |
4931 | + |
4932 | +#include <unity/api/scopes/internal/AbstractObject.h> |
4933 | + |
4934 | +namespace unity |
4935 | +{ |
4936 | + |
4937 | +namespace api |
4938 | +{ |
4939 | + |
4940 | +namespace scopes |
4941 | +{ |
4942 | + |
4943 | +namespace internal |
4944 | +{ |
4945 | + |
4946 | +AbstractObject::AbstractObject() |
4947 | +{ |
4948 | +} |
4949 | + |
4950 | +AbstractObject::~AbstractObject() noexcept |
4951 | +{ |
4952 | +} |
4953 | + |
4954 | +} // namespace internal |
4955 | + |
4956 | +} // namespace scopes |
4957 | + |
4958 | +} // namespace api |
4959 | + |
4960 | +} // namespace unity |
4961 | |
4962 | === modified file 'src/unity/api/scopes/internal/CMakeLists.txt' |
4963 | --- src/unity/api/scopes/internal/CMakeLists.txt 2013-06-18 09:02:02 +0000 |
4964 | +++ src/unity/api/scopes/internal/CMakeLists.txt 2013-08-05 06:40:36 +0000 |
4965 | @@ -1,7 +1,38 @@ |
4966 | +add_subdirectory(ice_middleware) |
4967 | + |
4968 | set(SRC |
4969 | + ${CMAKE_CURRENT_SOURCE_DIR}/AbstractObject.cpp |
4970 | + ${CMAKE_CURRENT_SOURCE_DIR}/ConfigBase.cpp |
4971 | ${CMAKE_CURRENT_SOURCE_DIR}/DynamicLoader.cpp |
4972 | ${CMAKE_CURRENT_SOURCE_DIR}/MiddlewareBase.cpp |
4973 | + ${CMAKE_CURRENT_SOURCE_DIR}/MiddlewareFactory.cpp |
4974 | + ${CMAKE_CURRENT_SOURCE_DIR}/MiddlewareFactoryConfig.cpp |
4975 | + ${CMAKE_CURRENT_SOURCE_DIR}/MWObject.cpp |
4976 | + ${CMAKE_CURRENT_SOURCE_DIR}/MWObjectProxy.cpp |
4977 | + ${CMAKE_CURRENT_SOURCE_DIR}/MWRegistryProxy.cpp |
4978 | + ${CMAKE_CURRENT_SOURCE_DIR}/MWReplyProxy.cpp |
4979 | + ${CMAKE_CURRENT_SOURCE_DIR}/MWScopeProxy.cpp |
4980 | + ${CMAKE_CURRENT_SOURCE_DIR}/RegistryConfig.cpp |
4981 | + ${CMAKE_CURRENT_SOURCE_DIR}/RegistryObject.cpp |
4982 | + ${CMAKE_CURRENT_SOURCE_DIR}/RegistryProxyImpl.cpp |
4983 | + ${CMAKE_CURRENT_SOURCE_DIR}/ReplyObject.cpp |
4984 | + ${CMAKE_CURRENT_SOURCE_DIR}/ReplyProxyImpl.cpp |
4985 | + ${CMAKE_CURRENT_SOURCE_DIR}/RuntimeConfig.cpp |
4986 | + ${CMAKE_CURRENT_SOURCE_DIR}/RuntimeImpl.cpp |
4987 | ${CMAKE_CURRENT_SOURCE_DIR}/ScopeLoader.cpp |
4988 | + ${CMAKE_CURRENT_SOURCE_DIR}/ScopeObject.cpp |
4989 | + ${CMAKE_CURRENT_SOURCE_DIR}/ScopeProxyImpl.cpp |
4990 | ) |
4991 | |
4992 | set(UNITY_SCOPES_LIB_SRC ${UNITY_SCOPES_LIB_SRC} ${SRC} PARENT_SCOPE) |
4993 | + |
4994 | +set(CONFIG_FILE_PREFIX "var/unity/api/scopes/config") |
4995 | + |
4996 | +configure_file(Registry.config.in ${CMAKE_CURRENT_BINARY_DIR}/Registry.config) |
4997 | + |
4998 | +add_executable(scope-registry RegistryMain.cpp ice_middleware/RegistryI.cpp) |
4999 | +target_link_libraries(scope-registry ${UNITY_SCOPES_LIB} ${OTHER_LIBS}) |
5000 | + |
The diff has been truncated for viewing.