-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add auxiliary API for Proxy #313
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add unit tests or/and test showing the usage of new functionality.
49e8038
to
34a29fd
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not understand the test. Are you testing setter/getter pair?
StandartObserver < std::function<void()> > * obs1 = new StandartObserver < std::function<void()> >(std::bind(&Counter::setValue1, &c1) ); | ||
SingleTimeObserver< std::function<void()> > * obs2 = new SingleTimeObserver< std::function<void()> >(std::bind(&Counter::setValue2, &c2) ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mem leak x 2
65649c8
to
5dd42d0
Compare
TEST_F(IPCProxyBaseTest, setObservers) | ||
{ | ||
const auto expected = std::vector<IObserver*>{obs1, obs2,}; | ||
proxyBase.m_readyObserver.setObservers(expected); | ||
const auto actual = proxyBase.m_readyObserver.getObservers(); | ||
EXPECT_EQ(expected.size(), actual.size()); | ||
EXPECT_EQ(expected[0], actual[0]); | ||
EXPECT_EQ(expected[1], actual[1]); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you test?
Could you test the actual usage of new functionality?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not a complete test cases. I will inform you.
Wait, please.
5dd42d0
to
2b38638
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please align the code ( curly braces etc)
2b38638
to
cc5fa36
Compare
src/ipc/ipc-common/observer.h
Outdated
{ | ||
Q_OBJECT | ||
public: | ||
virtual void onReadyChanged(std::shared_ptr<QMetaObject::Connection> connection) = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do you use std::shared_ptr ?
Isn't it enough to use std::unique_ptr + std::make_unique ?
Of course, this also applies to other parts of PR.
find_package(GTest) | ||
if(${GTEST_FOUND}) | ||
find_library(GMOCK_LIBRARY gmock REQUIRED HINTS "${CMAKE_SYSTEM_PREFIX_PATH}") | ||
if(NOT ${GMOCK_LIBRARY} STREQUAL "GMOCK_LIBRARY-NOTFOUND") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
verify if it's enough to use if(GMOCK_LIBRARY-NOTFOUND) instead and reverse logic
a09fa13
to
9c55e92
Compare
9c55e92
to
8dfd591
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I ask you reply all the comments!
At least: "Done", "not needed", "to be done", or answer to the question.
Otherwise I cannot see any reason for wasting the time and doing reviews when
your comments picked selectively and yours questions are ignored!
src/ipc/ipc-common/IPCProxyBase.h
Outdated
@@ -49,10 +49,12 @@ class IPCProxyBase : public AdapterType, protected IPCProxyBaseBase | |||
|
|||
public: | |||
using InterfaceType = AdapterType; | |||
IsReadyObserver m_readyObserver{}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is it here? We discussed that already that we do not want to extend this class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please move it from this class. We do not want it here!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
src/ipc/ipc-common/observer.h
Outdated
{ | ||
Q_OBJECT | ||
public: | ||
virtual void onReadyChanged(std::shared_ptr<QMetaObject::Connection> connection) = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IObserver::onReadyChanged? I think this method should be in IsReadyObserver.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
public: | ||
Counter c1; | ||
Counter c2; | ||
StandartObserver < std::function<void()> > * obs1 = new StandartObserver < std::function<void()> > (std::bind(&Counter::incValue, &c1) ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
std::unique_ptr?
Why not just make it a member of the class (not a pointer)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
// Check values after signal call | ||
ASSERT_EQ(c1.getValue(), 3); // for StandartObserver | ||
ASSERT_EQ(c2.getValue(), 1); // for SingleTimeObserver | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You do not test the functionality. Also I am not quite sure how to use your observer, which was meant to be similar to discussed "callOnceReady" and "callOnReady".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added comments for the test, which briefly describes the sequence of work and interaction between "Proxy", "IsReadyObserver" and observers for "callOnReady", "callOnceReady". Instead "Proxy" there may be a different type and signal.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The main goal is to have a flexible service, present as independent/extern component, that reacts on certain states of one object of inspection and execute vary callbacks either once or permanent.
In general it is intend for a Qt objects a certain kind of types, that has the "ready" state, it is necessary to provide the ability to track this state using the "IsReadyObserver" component and an arbitrary number of observers of two types: "callOnReady" and "callOnceReady", which are callbacks. The ready state is determined by a specific signal that emitted from inspected object and "ready" state. The "IsReadyObserver" is the watcher of the signal of interest in "Proxy" and contain observers with callback to execute.
INSTALLATION: the user creates an "IsReadyObserver" and sets in it: the object's address, the object's interface signal and the object's readiness function. After that set/load observers to "IsReadyObserver".
For example:
readyObserver.watch( &proxy, &IPCProxy<InterfaceBase>::readyChanged, &IPCProxy<InterfaceBase>::ready );
CONDITION FOR PROCESSING: for the inspected object, the interface signal has changed, while the ready property is in the "ready" state. In this case, the callback in observers will be executed once.
If the interface signal for the inspected object has changed, but the ready property is in the "not ready" state. In this case, the callback in observers will not executed.
REQUIREMENT: One change in the interface signal and "ready" state corresponds to a single execution of the callback. No signal can be missed.
Main steps:
- Creation of main objects: object for inspection "Proxy" (this is one of more possible types), object for observation "IsReadyObserver", objects for executing "Observers".
- Installing objects/function to be executed in observers depending on the need: "callOnReady" or "callOnceReady".
- Setting up to "IsReadyObserver" to watch out for signal in "Proxy".
- Catching signal and execution of callback.
- Completion of work.
Testing:
- Functionality check and main life cycle of components (creation, execution, completion)
- Processing of erroneous or incorrect data
- Memory leaks and undefined behavior
- Load testing for performance (performance, latency, metrics).
- Stress testing for failure
Possible points 1-4 are minimal necessary.
dab4130
to
348bc4e
Compare
348bc4e
to
6b91de3
Compare
fc6256e
to
e1fb63b
Compare
fa68d46
to
0b53b18
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add observer.cpp and move an appropriate code there
acf860f
to
acd86a1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please fix tests. I have not idea what they test, because you created two test cases within the test fixture, but it looks like there should be at least 10 of them. Please split them into separate TEST_F.
I don't understand the point of IObserver and its virtual method. Could you explain it please?
src/ipc/ipc-common/observer.h
Outdated
{ | ||
Q_OBJECT | ||
public: | ||
virtual void IsReadyObserver(const std::shared_ptr<QMetaObject::Connection> &connection) = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this method? Why?
tests/unittest/CMakeLists.txt
Outdated
@@ -6,18 +6,34 @@ if(${GTEST_FOUND}) | |||
add_library(GTest::GMock UNKNOWN IMPORTED) | |||
set_target_properties(GTest::GMock PROPERTIES IMPORTED_LOCATION ${GMOCK_LIBRARY}) | |||
else() | |||
message(WARNING "Google test/mock not found.") | |||
message(ERROR "Google test/mock not found.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be warning! If there are not gtest installed, we just ignore these!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
tests/unittest/CMakeLists.txt
Outdated
else() | ||
message(WARNING "Required package google test not found!") | ||
message(ERROR "Required package google test not found!") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WARNING!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
/********************************************************************** | ||
** The main goal is to have a flexible service, present as independent/extern component, that reacts on certain states of one object of inspection and execute vary functors either once or permanent. | ||
** In general it is intend for a Qt objects a certain kind of types, that has the "ready" state, it is necessary to provide the ability to track this state using the "IsReadyObserver" component and an arbitrary number of observers of two types: "callOnReady" and "callOnceReady", which are functors. The ready state is determined by a specific signal that emitted from inspected object and "ready" state. | ||
** The "IsReadyObserver" is the watcher of the signal of interest in "Proxy" and contain observers with functors to execute. | ||
** INSTALLATION: the user creates an "IsReadyObserver" and sets in it: the object's address, the object's interface signal and the object's readiness function. After that set/load observers to "IsReadyObserver". | ||
** For example: | ||
** readyObserver.watch( &proxy, &IPCProxy<InterfaceBase>::readyChanged, &IPCProxy<InterfaceBase>::ready ); | ||
** CONDITION FOR PROCESSING: for the inspected object, the interface signal has changed, while the ready property is in the "ready" state. In this case, the functors in observers will be executed once. | ||
** If the interface signal for the inspected object has changed, but the ready property is in the "not ready" state. In this case, the functors in observers will not executed. | ||
** REQUIREMENT: One change in the interface signal and "ready" state corresponds to a single execution of the functor. No signal can be missed. | ||
** Main steps: | ||
** - Creation of main objects: object for inspection "Proxy" (this is one of more possible types), object for observation "IsReadyObserver", objects for executing "Observers". | ||
** - Installing objects/function to be executed in observers depending on the need: "callOnReady" or "callOnceReady". | ||
** - Setting up to "IsReadyObserver" to watch out for signal in "Proxy". | ||
** - Catching signal and execution of functors. | ||
** - Completion of work. | ||
**********************************************************************/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Why you add something like this here? This is test, not a documentation. I have not checked the content, because it should not be here.
- This formatting is like from 90'. Please remove unnecessary stars.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just for convenience. I did remove it.
Done
/********************************************************************** | ||
** INPUT: property of Proxy ready() in state disabled, trigger changeReady() is toggles 3 times. | ||
** OUTPUT: No observer should be executed. | ||
**********************************************************************/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove or make it readable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
/********************************************************************** | ||
** INPUT: property of Proxy ready() in state enabled, trigger changeReady() is toggles 3 times. | ||
** OUTPUT: All observer should be executed. | ||
**********************************************************************/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
03ef53d
to
508f66c
Compare
/** | ||
* @brief checking if proxy is ready and signal exists, all observer should be executed. | ||
* @param set to Proxy in state "true" | ||
* @param set 2 observers | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is not a place for doxygen documentation!!!!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
96b3ee5
to
4f8b2c9
Compare
cad5b4c
to
af34354
Compare
No description provided.