Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Cameo
cameo
Commits
9b2bf21b
Commit
9b2bf21b
authored
Oct 15, 2020
by
legoc
Browse files
(split) Implemented waitFor() with KeyValue in Instance
parent
d7af35f2
Changes
4
Hide whitespace changes
Inline
Side-by-side
include/Application.h
View file @
9b2bf21b
...
@@ -35,6 +35,7 @@
...
@@ -35,6 +35,7 @@
#include "Services.h"
#include "Services.h"
#include "TimeCondition.h"
#include "TimeCondition.h"
#include "EventListener.h"
#include "EventListener.h"
#include "KeyValue.h"
namespace
cameo
{
namespace
cameo
{
...
@@ -210,6 +211,7 @@ public:
...
@@ -210,6 +211,7 @@ public:
State
waitFor
(
StateHandlerType
handler
=
nullptr
);
State
waitFor
(
StateHandlerType
handler
=
nullptr
);
State
waitFor
(
int
states
,
StateHandlerType
handler
=
nullptr
);
State
waitFor
(
int
states
,
StateHandlerType
handler
=
nullptr
);
State
waitFor
(
const
std
::
string
&
eventName
);
State
waitFor
(
const
std
::
string
&
eventName
);
State
waitFor
(
KeyValue
&
keyValue
);
void
cancelWaitFor
();
void
cancelWaitFor
();
...
@@ -254,7 +256,7 @@ private:
...
@@ -254,7 +256,7 @@ private:
void
setOutputStreamSocket
(
std
::
unique_ptr
<
OutputStreamSocket
>&
socket
);
void
setOutputStreamSocket
(
std
::
unique_ptr
<
OutputStreamSocket
>&
socket
);
void
setPastStates
(
State
pastStates
);
void
setPastStates
(
State
pastStates
);
void
setInitialState
(
State
state
);
void
setInitialState
(
State
state
);
State
waitFor
(
int
states
,
const
std
::
string
&
eventName
,
StateHandlerType
handler
,
bool
blocking
);
State
waitFor
(
int
states
,
const
std
::
string
&
eventName
,
KeyValue
&
keyValue
,
StateHandlerType
handler
,
bool
blocking
);
Server
*
m_server
;
Server
*
m_server
;
std
::
shared_ptr
<
OutputStreamSocket
>
m_outputStreamSocket
;
std
::
shared_ptr
<
OutputStreamSocket
>
m_outputStreamSocket
;
...
...
include/KeyValue.h
0 → 100644
View file @
9b2bf21b
/*
* Copyright 2015 Institut Laue-Langevin
*
* Licensed under the EUPL, Version 1.1 only (the "License");
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at:
*
* http://joinup.ec.europa.eu/software/page/eupl
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the Licence is distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions and
* limitations under the Licence.
*/
#ifndef CAMEO_KEYVALUE_H_
#define CAMEO_KEYVALUE_H_
#include <string>
namespace
cameo
{
class
KeyValue
{
public:
enum
Status
{
UNDEFINED
,
STORED
,
REMOVED
};
KeyValue
(
const
std
::
string
&
key
);
void
setStatus
(
Status
status
);
void
setValue
(
const
std
::
string
&
value
);
Status
getStatus
()
const
;
const
std
::
string
&
getKey
()
const
;
const
std
::
string
&
getValue
()
const
;
private:
Status
m_status
;
std
::
string
m_key
;
std
::
string
m_value
;
};
}
#endif
src/Application.cpp
View file @
9b2bf21b
...
@@ -42,6 +42,7 @@
...
@@ -42,6 +42,7 @@
#include "PublisherEvent.h"
#include "PublisherEvent.h"
#include "ResultEvent.h"
#include "ResultEvent.h"
#include "PortEvent.h"
#include "PortEvent.h"
#include "KeyEvent.h"
#include "CancelEvent.h"
#include "CancelEvent.h"
using
namespace
std
;
using
namespace
std
;
...
@@ -535,7 +536,7 @@ bool Instance::kill() {
...
@@ -535,7 +536,7 @@ bool Instance::kill() {
return
true
;
return
true
;
}
}
State
Instance
::
waitFor
(
int
states
,
const
std
::
string
&
eventName
,
StateHandlerType
handler
,
bool
blocking
)
{
State
Instance
::
waitFor
(
int
states
,
const
std
::
string
&
eventName
,
KeyValue
&
keyValue
,
StateHandlerType
handler
,
bool
blocking
)
{
if
(
!
exists
())
{
if
(
!
exists
())
{
// The application was not launched
// The application was not launched
...
@@ -613,6 +614,19 @@ State Instance::waitFor(int states, const std::string& eventName, StateHandlerTy
...
@@ -613,6 +614,19 @@ State Instance::waitFor(int states, const std::string& eventName, StateHandlerTy
break
;
break
;
}
}
}
}
else
if
(
KeyEvent
*
keyEvent
=
dynamic_cast
<
KeyEvent
*>
(
event
.
get
()))
{
if
(
keyEvent
->
getKey
()
==
keyValue
.
getKey
())
{
// Set the status and value.
if
(
keyEvent
->
getStatus
()
==
KeyEvent
::
Status
::
STORED
)
{
keyValue
.
setStatus
(
KeyValue
::
Status
::
STORED
);
}
else
{
keyValue
.
setStatus
(
KeyValue
::
Status
::
REMOVED
);
}
keyValue
.
setValue
(
keyEvent
->
getValue
());
break
;
}
}
else
if
(
CancelEvent
*
cancel
=
dynamic_cast
<
CancelEvent
*>
(
event
.
get
()))
{
else
if
(
CancelEvent
*
cancel
=
dynamic_cast
<
CancelEvent
*>
(
event
.
get
()))
{
break
;
break
;
}
}
...
@@ -624,15 +638,22 @@ State Instance::waitFor(int states, const std::string& eventName, StateHandlerTy
...
@@ -624,15 +638,22 @@ State Instance::waitFor(int states, const std::string& eventName, StateHandlerTy
}
}
State
Instance
::
waitFor
(
int
states
,
StateHandlerType
handler
)
{
State
Instance
::
waitFor
(
int
states
,
StateHandlerType
handler
)
{
return
waitFor
(
states
,
""
,
handler
,
true
);
KeyValue
keyValue
(
""
);
return
waitFor
(
states
,
""
,
keyValue
,
handler
,
true
);
}
}
State
Instance
::
waitFor
(
StateHandlerType
handler
)
{
State
Instance
::
waitFor
(
StateHandlerType
handler
)
{
return
waitFor
(
0
,
""
,
handler
,
true
);
KeyValue
keyValue
(
""
);
return
waitFor
(
0
,
""
,
keyValue
,
handler
,
true
);
}
}
State
Instance
::
waitFor
(
const
std
::
string
&
eventName
)
{
State
Instance
::
waitFor
(
const
std
::
string
&
eventName
)
{
return
waitFor
(
0
,
eventName
,
nullptr
,
true
);
KeyValue
keyValue
(
""
);
return
waitFor
(
0
,
eventName
,
keyValue
,
nullptr
,
true
);
}
State
Instance
::
waitFor
(
KeyValue
&
keyValue
)
{
return
waitFor
(
0
,
""
,
keyValue
,
nullptr
,
true
);
}
}
void
Instance
::
cancelWaitFor
()
{
void
Instance
::
cancelWaitFor
()
{
...
@@ -646,8 +667,8 @@ State Instance::now() {
...
@@ -646,8 +667,8 @@ State Instance::now() {
}
}
State
Instance
::
getLastState
()
{
State
Instance
::
getLastState
()
{
KeyValue
keyValue
(
""
);
return
waitFor
(
0
,
""
,
nullptr
,
false
);
return
waitFor
(
0
,
""
,
keyValue
,
nullptr
,
false
);
}
}
State
Instance
::
getActualState
()
const
{
State
Instance
::
getActualState
()
const
{
...
...
src/KeyValue.cpp
0 → 100644
View file @
9b2bf21b
/*
* Copyright 2015 Institut Laue-Langevin
*
* Licensed under the EUPL, Version 1.1 only (the "License");
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at:
*
* http://joinup.ec.europa.eu/software/page/eupl
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the Licence is distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions and
* limitations under the Licence.
*/
#include "KeyValue.h"
namespace
cameo
{
KeyValue
::
KeyValue
(
const
std
::
string
&
key
)
:
m_status
(
Status
::
UNDEFINED
),
m_key
(
key
)
{
}
void
KeyValue
::
setStatus
(
Status
status
)
{
m_status
=
status
;
}
void
KeyValue
::
setValue
(
const
std
::
string
&
value
)
{
m_value
=
value
;
}
KeyValue
::
Status
KeyValue
::
getStatus
()
const
{
return
m_status
;
}
const
std
::
string
&
KeyValue
::
getKey
()
const
{
return
m_key
;
}
const
std
::
string
&
KeyValue
::
getValue
()
const
{
return
m_value
;
}
}
Shervin Nourbakhsh
@nourbakhsh
mentioned in commit
46e44691
·
Apr 23, 2021
mentioned in commit
46e44691
mentioned in commit 46e44691a03808a23a464818487b0dd014a9c57e
Toggle commit list
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment