Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
N
ngraph
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
ngraph
Commits
f65fdf82
Commit
f65fdf82
authored
Aug 21, 2017
by
Avijit
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Renamed the functions and ran clang-format.
parent
6ec2b865
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
24 deletions
+25
-24
ngraph.cpp
src/ngraph.cpp
+4
-4
ngraph.hpp
src/ngraph.hpp
+5
-6
ngraph.cpp
test/ngraph.cpp
+16
-14
No files found.
src/ngraph.cpp
View file @
f65fdf82
...
...
@@ -14,20 +14,20 @@
#include "ngraph.hpp"
#include "log.hpp"
NGraph
*
create_
plugin
()
NGraph
*
create_
ngraph_object
()
{
return
new
NGraph
();
}
void
destroy_
plugin
(
NGraph
*
pObj
)
void
destroy_
ngraph_object
(
NGraph
*
pObj
)
{
delete
pObj
;
}
void
NGraph
::
add_params
(
const
std
::
vector
<
std
::
string
>&
paramList
)
void
NGraph
::
add_params
(
const
std
::
vector
<
std
::
string
>&
paramList
)
{
INFO
<<
"Adding parameters"
;
m_params
.
insert
(
m_params
.
end
(),
paramList
.
begin
(),
paramList
.
end
());
m_params
.
insert
(
m_params
.
end
(),
paramList
.
begin
(),
paramList
.
end
());
}
const
std
::
vector
<
std
::
string
>&
NGraph
::
get_params
()
const
...
...
src/ngraph.hpp
View file @
f65fdf82
...
...
@@ -21,16 +21,15 @@ class NGraph
public
:
void
add_params
(
const
std
::
vector
<
std
::
string
>&
paramList
);
const
std
::
vector
<
std
::
string
>&
get_params
()
const
;
std
::
string
get_name
()
const
{
return
"NGraph Plugin"
;
}
std
::
string
get_name
()
const
{
return
"NGraph Implementation Object"
;
}
private
:
std
::
vector
<
std
::
string
>
m_params
;
};
// Factory methods
extern
"C"
NGraph
*
create_
plugin
();
extern
"C"
void
destroy_
plugin
(
NGraph
*
pObj
);
extern
"C"
NGraph
*
create_
ngraph_object
();
extern
"C"
void
destroy_
ngraph_object
(
NGraph
*
pObj
);
// FUnction pointers to the factory methods
typedef
NGraph
*
(
*
Create
Plugin
Pfn
)();
typedef
void
(
*
DestroyPlugin
Pfn
)(
NGraph
*
);
typedef
NGraph
*
(
*
Create
NGraphObj
Pfn
)();
typedef
void
(
*
DestroyNGraphObj
Pfn
)(
NGraph
*
);
test/ngraph.cpp
View file @
f65fdf82
...
...
@@ -27,8 +27,8 @@ using namespace std;
TEST
(
NGraph
,
loadTest
)
{
// load the triangle library
void
*
plugin
Lib
=
dlopen
(
"../src/libngraph.so"
,
RTLD_LAZY
);
if
(
!
plugin
Lib
)
void
*
ngraphImpl
Lib
=
dlopen
(
"../src/libngraph.so"
,
RTLD_LAZY
);
if
(
!
ngraphImpl
Lib
)
{
std
::
cerr
<<
"Cannot load library: "
<<
dlerror
()
<<
'\n'
;
ASSERT_FALSE
(
true
);
...
...
@@ -38,33 +38,35 @@ TEST(NGraph, loadTest)
dlerror
();
// Get the symbols
auto
createPfn
=
reinterpret_cast
<
CreatePluginPfn
>
(
dlsym
(
pluginLib
,
"create_plugin"
));
auto
createPfn
=
reinterpret_cast
<
CreateNGraphObjPfn
>
(
dlsym
(
ngraphImplLib
,
"create_ngraph_object"
));
ASSERT_FALSE
(
createPfn
==
nullptr
);
auto
destroyPfn
=
reinterpret_cast
<
DestroyPluginPfn
>
(
dlsym
(
pluginLib
,
"destroy_plugin"
));
auto
destroyPfn
=
reinterpret_cast
<
DestroyNGraphObjPfn
>
(
dlsym
(
ngraphImplLib
,
"destroy_ngraph_object"
));
ASSERT_FALSE
(
destroyPfn
==
nullptr
);
NGraph
*
plugin
Obj
=
createPfn
();
NGraph
*
nGraph
Obj
=
createPfn
();
INFO
<<
"Call a method on the Object"
;
ASSERT_EQ
(
"NGraph
Plugin"
,
plugin
Obj
->
get_name
());
INFO
<<
"
Plugin Name: "
<<
plugin
Obj
->
get_name
();
ASSERT_EQ
(
"NGraph
Implementation Object"
,
nGraph
Obj
->
get_name
());
INFO
<<
"
Object Name: "
<<
nGraph
Obj
->
get_name
();
// Add some parameters
const
vector
<
string
>
TEST_PARAMS
=
{
"param-1"
,
"param-2"
,
"param-3"
};
pluginObj
->
add_params
(
TEST_PARAMS
);
nGraphObj
->
add_params
(
TEST_PARAMS
);
// Get the list of params
auto
&
storedParams
=
plugin
Obj
->
get_params
();
EXPECT_EQ
(
TEST_PARAMS
.
size
(),
storedParams
.
size
()
);
auto
&
storedParams
=
nGraph
Obj
->
get_params
();
EXPECT_EQ
(
TEST_PARAMS
.
size
(),
storedParams
.
size
()
);
for
(
int
i
=
0
;
i
<
TEST_PARAMS
.
size
();
i
++
)
{
EXPECT_EQ
(
TEST_PARAMS
[
i
],
storedParams
[
i
]
);
EXPECT_EQ
(
TEST_PARAMS
[
i
],
storedParams
[
i
]
);
}
INFO
<<
"Destroy the
Plugin
Object"
;
destroyPfn
(
plugin
Obj
);
INFO
<<
"Destroy the
NGraph
Object"
;
destroyPfn
(
nGraph
Obj
);
dlclose
(
plugin
Lib
);
dlclose
(
ngraphImpl
Lib
);
}
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