Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
I
ipaaca
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Admin message
Looking for advice? Join the
Matrix channel for GitLab users in Bielefeld
!
Show more breadcrumbs
Social Cognitive Systems
ipaaca
Commits
1e4e2782
Commit
1e4e2782
authored
12 years ago
by
Ramin Yaghoubzadeh
Browse files
Options
Downloads
Patches
Plain Diff
Committing before adding the remoteServer code
parent
a1578510
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
cpp/src/ipaaca-test-main.cc
+5
-81
5 additions, 81 deletions
cpp/src/ipaaca-test-main.cc
cpp/src/ipaaca.cc
+46
-5
46 additions, 5 deletions
cpp/src/ipaaca.cc
cpp/src/ipaaca.h
+19
-13
19 additions, 13 deletions
cpp/src/ipaaca.h
with
70 additions
and
99 deletions
cpp/src/ipaaca-test-main.cc
+
5
−
81
View file @
1e4e2782
...
...
@@ -5,84 +5,6 @@
//#include <rsc/logging/LoggerFactory.h>
// //rsc::logging::LoggerFactory::getInstance().reconfigure(rsc::logging::Logger::LEVEL_ALL);
#if 0
//boost::mutex mtx;
using namespace ipaaca;
class Testo {
protected:
std::string _name;
public:
inline Testo(const std::string& name="Testo"): _name(name) { }
inline void handleIUEvent(EventPtr event)
{
std::cout << _name << " received a ";
std::string type = event->getType();
if (type == "ipaaca::IUPayloadUpdate") {
std::cout << *boost::static_pointer_cast<IUPayloadUpdate>(event->getData()) << std::endl;
} else if (type == "ipaaca::IULinkUpdate") {
std::cout << *boost::static_pointer_cast<IULinkUpdate>(event->getData()) << std::endl;
} else {
std::cout << type << " (Unhandled type!)" << std::endl;
}
}
};
int main() {
initialize_ipaaca_rsb();
ListenerPtr listener = Factory::getInstance().createListener( Scope("/tutorial/converter"));
Testo t("TESTO");
HandlerPtr event_handler = HandlerPtr(new EventFunctionHandler(boost::bind(&Testo::handleIUEvent, boost::ref(t), _1)));
listener->addHandler( event_handler );
while(true) {
boost::this_thread::sleep(boost::posix_time::milliseconds(100));
}
return EXIT_SUCCESS;
}
//
//
//
//
using namespace ipaaca;
int main() {
initialize_ipaaca_rsb();
//Informer<ipaaca::IUPayloadUpdate>::Ptr pinformer = Factory::getInstance().createInformer<ipaaca::IUPayloadUpdate> ( Scope("/tutorial/converter"));
//Informer<ipaaca::IULinkUpdate>::Ptr linformer = Factory::getInstance().createInformer<ipaaca::IULinkUpdate> ( Scope("/tutorial/converter"));
Informer<AnyType>::Ptr informer = Factory::getInstance().createInformer<AnyType> ( Scope("/tutorial/converter"));
IUPayloadUpdate* pup = new ipaaca::IUPayloadUpdate();
Informer<ipaaca::IUPayloadUpdate>::DataPtr pdata(pup);
pup->uid = "2000";
pup->revision = 3;
pup->writer_name = "Comp1_OB";
pup->is_delta = true;
pup->new_items["new_key"] = "new_value";
pup->new_items["another_key"] = "some_info";
pup->keys_to_remove.push_back("old_key");
informer->publish(pdata);
IULinkUpdate* lup = new ipaaca::IULinkUpdate();
Informer<ipaaca::IULinkUpdate>::DataPtr ldata(lup);
lup->uid = "2001";
lup->revision = 4;
lup->writer_name = "Comp2_IB";
lup->is_delta = true;
lup->new_links["SLL"].insert("2000");
lup->new_links["grin"].insert("1002");
lup->links_to_remove["grin"].insert("1001");
informer->publish(ldata);
std::cout << "Done." << std::endl;
return EXIT_SUCCESS;
}
#endif
//
// TESTS
//
...
...
@@ -94,7 +16,7 @@ int main() {
try
{
initialize_ipaaca_rsb
();
InputBuffer
ib
(
"Test
IB
"
,
"testcategory"
);
InputBuffer
ib
(
"Test
er
"
,
"testcategory"
);
while
(
true
)
{
...
...
@@ -112,7 +34,7 @@ int main() {
initialize_ipaaca_rsb
();
OutputBuffer
ob
(
"Test
OB
"
);
OutputBuffer
ob
(
"Test
er
"
);
std
::
cout
<<
"Buffer: "
<<
ob
.
unique_name
()
<<
std
::
endl
;
IU
::
ref
iu
=
IU
::
create
(
"testcategory"
);
...
...
@@ -125,7 +47,9 @@ int main() {
std
::
string
s
=
"The string
\"
"
+
iu
->
_payload
[
"TEST"
].
to_str
()
+
"
\"
is the new value."
;
std
::
cout
<<
"Concatenation test: "
<<
s
<<
std
::
endl
;
iu
->
add_link
(
"grin"
,
"DUMMY_IU_UID"
);
std
::
cout
<<
"Interpreted as long value: "
<<
iu
->
_payload
[
"TEST"
].
to_int
()
<<
std
::
endl
;
std
::
cout
<<
"Interpreted as double value: "
<<
iu
->
_payload
[
"TEST"
].
to_float
()
<<
std
::
endl
;
iu
->
commit
();
...
...
This diff is collapsed.
Click to expand it.
cpp/src/ipaaca.cc
+
46
−
5
View file @
1e4e2782
...
...
@@ -47,6 +47,24 @@ void init_inprocess_too() {
*/
//}}}
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
const
SmartLinkMap
&
obj
)
//{{{
{
os
<<
"{"
;
bool
first
=
true
;
for
(
LinkMap
::
const_iterator
it
=
obj
.
_links
.
begin
();
it
!=
obj
.
_links
.
end
();
++
it
)
{
if
(
first
)
{
first
=
false
;
}
else
{
os
<<
", "
;
}
os
<<
"'"
<<
it
->
first
<<
"': ["
;
bool
firstinner
=
true
;
for
(
LinkSet
::
const_iterator
it2
=
it
->
second
.
begin
();
it2
!=
it
->
second
.
end
();
++
it2
)
{
if
(
firstinner
)
{
firstinner
=
false
;
}
else
{
os
<<
", "
;
}
os
<<
"'"
<<
*
it2
<<
"'"
;
}
os
<<
"]"
;
}
os
<<
"}"
;
return
os
;
}
//}}}
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
const
Payload
&
obj
)
//{{{
{
os
<<
"{"
;
...
...
@@ -61,11 +79,15 @@ std::ostream& operator<<(std::ostream& os, const Payload& obj)//{{{
//}}}
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
const
IUInterface
&
obj
)
//{{{
{
os
<<
"IUInterface(uid="
<<
obj
.
uid
()
<<
", revision="
<<
obj
.
revision
();
os
<<
", owner_name="
<<
obj
.
owner_name
();
os
<<
", payload = "
;
bool
first
=
true
;
os
<<
"IUInterface(uid='"
<<
obj
.
uid
()
<<
"'"
;
os
<<
", category='"
<<
obj
.
category
()
<<
"'"
;
os
<<
", revision="
<<
obj
.
revision
();
os
<<
", committed="
<<
(
obj
.
committed
()
?
"True"
:
"False"
);
os
<<
", owner_name='"
<<
obj
.
owner_name
()
<<
"'"
;
os
<<
", payload="
;
os
<<
obj
.
const_payload
();
os
<<
", links="
;
os
<<
obj
.
_links
;
os
<<
")"
;
return
os
;
}
...
...
@@ -520,6 +542,25 @@ void IUInterface::_associate_with_buffer(Buffer* buffer) { //boost::shared_ptr<B
payload
().
_set_owner_name
(
buffer
->
unique_name
());
}
/// C++-specific convenience function to add one single link
void
IUInterface
::
add_link
(
const
std
::
string
&
type
,
const
std
::
string
&
target
,
const
std
::
string
&
writer_name
)
{
LinkMap
none
;
LinkMap
add
;
add
[
type
].
insert
(
target
);
_modify_links
(
true
,
add
,
none
,
writer_name
);
_add_and_remove_links
(
add
,
none
);
}
/// C++-specific convenience function to remove one single link
void
IUInterface
::
remove_link
(
const
std
::
string
&
type
,
const
std
::
string
&
target
,
const
std
::
string
&
writer_name
)
{
LinkMap
none
;
LinkMap
remove
;
remove
[
type
].
insert
(
target
);
_modify_links
(
true
,
none
,
remove
,
writer_name
);
_add_and_remove_links
(
none
,
remove
);
}
void
IUInterface
::
add_links
(
const
std
::
string
&
type
,
const
LinkSet
&
targets
,
const
std
::
string
&
writer_name
)
{
LinkMap
none
;
...
...
@@ -674,7 +715,7 @@ void RemotePushIU::_apply_update(IUPayloadUpdate::ptr update)
}
void
RemotePushIU
::
_apply_commission
()
{
IPAACA_IMPLEMENT_ME
_committed
=
true
;
}
void
Payload
::
_remotely_enforced_wipe
()
{
...
...
This diff is collapsed.
Click to expand it.
cpp/src/ipaaca.h
+
19
−
13
View file @
1e4e2782
...
...
@@ -131,6 +131,7 @@ class Lock
typedef
std
::
set
<
std
::
string
>
LinkSet
;
typedef
std
::
map
<
std
::
string
,
LinkSet
>
LinkMap
;
class
SmartLinkMap
{
friend
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
const
SmartLinkMap
&
obj
);
friend
class
IUInterface
;
friend
class
IU
;
friend
class
IUConverter
;
...
...
@@ -147,7 +148,7 @@ class SmartLinkMap {
const
LinkSet
EMPTY_LINK_SET
;
//const std::set<std::string> EMPTY_LINK_SET;
class
Buffer
{
//: public boost::enable_shared_from_this<Buffer> {
class
Buffer
{
//: public boost::enable_shared_from_this<Buffer> {
//{{{
friend
class
IU
;
friend
class
RemotePushIU
;
protected:
...
...
@@ -168,8 +169,9 @@ class Buffer { //: public boost::enable_shared_from_this<Buffer> {
inline
const
std
::
string
&
unique_name
()
{
return
_unique_name
;
}
//_IPAACA_ABSTRACT_ virtual void add(boost::shared_ptr<IUInterface> iu) = 0;
};
//}}}
class
OutputBuffer
:
public
Buffer
{
//, public boost::enable_shared_from_this<OutputBuffer> {
class
OutputBuffer
:
public
Buffer
{
//, public boost::enable_shared_from_this<OutputBuffer> {
//{{{
friend
class
IU
;
friend
class
RemotePushIU
;
protected:
...
...
@@ -198,8 +200,9 @@ class OutputBuffer: public Buffer { //, public boost::enable_shared_from_this<Ou
boost
::
shared_ptr
<
IU
>
remove
(
const
std
::
string
&
iu_uid
);
boost
::
shared_ptr
<
IU
>
remove
(
boost
::
shared_ptr
<
IU
>
iu
);
};
//}}}
class
InputBuffer
:
public
Buffer
{
//, public boost::enable_shared_from_this<InputBuffer> {
class
InputBuffer
:
public
Buffer
{
//, public boost::enable_shared_from_this<InputBuffer> {
//{{{
friend
class
IU
;
friend
class
RemotePushIU
;
protected:
...
...
@@ -237,16 +240,7 @@ class InputBuffer: public Buffer { //, public boost::enable_shared_from_this<Inp
// IPAACA_IMPLEMENT_ME
//}
};
/*
class IUEventFunctionHandler: public rsb::EventFunctionHandler {
protected:
Buffer* _buffer;
public:
inline IUEventFunctionHandler(Buffer* buffer, const EventFunction& function, const std::string& method="")
: EventFunctionHandler(function, method), _buffer(buffer) { }
};
*/
//}}}
class
IUConverter
:
public
rsb
::
converter
::
Converter
<
std
::
string
>
{
//{{{
public:
...
...
@@ -514,6 +508,18 @@ class NotImplementedError: public Exception//{{{
}
};
//}}}
// (snippets) //{{{
/*
class IUEventFunctionHandler: public rsb::EventFunctionHandler {
protected:
Buffer* _buffer;
public:
inline IUEventFunctionHandler(Buffer* buffer, const EventFunction& function, const std::string& method="")
: EventFunctionHandler(function, method), _buffer(buffer) { }
};
*/
//}}}
}
// of namespace ipaaca
#endif
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment