Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
ORNL Quantum Computing Institute
xacc
Commits
19d8426a
Commit
19d8426a
authored
Jan 30, 2018
by
Mccaskey, Alex
Browse files
Adding info statements to plugin loading
Signed-off-by:
Alex McCaskey
<
mccaskeyaj@ornl.gov
>
parent
a694420c
Changes
3
Hide whitespace changes
Inline
Side-by-side
xacc/XACC.cpp
View file @
19d8426a
...
...
@@ -53,7 +53,13 @@ void Initialize(int arc, char** arv) {
// Get reference to the service registry
auto
serviceRegistry
=
xacc
::
ServiceRegistry
::
instance
();
serviceRegistry
->
initialize
();
try
{
serviceRegistry
->
initialize
();
}
catch
(
std
::
exception
&
e
)
{
XACCLogger
::
instance
()
->
error
(
std
::
string
(
e
.
what
())
+
" - Could not initialize XACC Framework"
);
}
// Parse any user-supplied command line options
xaccCLParser
->
parse
(
argc
,
argv
);
...
...
@@ -170,6 +176,11 @@ std::shared_ptr<Accelerator> getAccelerator(const std::string& name) {
}
bool
hasAccelerator
(
const
std
::
string
&
name
)
{
if
(
!
xacc
::
xaccFrameworkInitialized
)
{
error
(
"XACC not initialized before use. Please execute "
"xacc::Initialize() before using API."
);
}
return
ServiceRegistry
::
instance
()
->
hasService
<
Accelerator
>
(
name
);
}
...
...
xacc/utils/ServiceRegistry.cpp
View file @
19d8426a
...
...
@@ -6,15 +6,9 @@ void ServiceRegistry::initialize() {
if
(
!
initialized
)
{
framework
=
FrameworkFactory
().
NewFramework
();
try
{
// Initialize the framework, such that we can call
// GetBundleContext() later.
framework
.
Init
();
}
catch
(
const
std
::
exception
&
e
)
{
XACCLogger
::
instance
()
->
error
(
std
::
string
(
e
.
what
())
+
" - Could not initialize XACC Framework"
);
}
// Initialize the framework, such that we can call
// GetBundleContext() later.
framework
.
Init
();
context
=
framework
.
GetBundleContext
();
if
(
!
context
)
{
...
...
@@ -23,12 +17,13 @@ void ServiceRegistry::initialize() {
}
const
std
::
string
xaccLibDir
=
std
::
string
(
XACC_INSTALL_DIR
)
+
std
::
string
(
"/lib"
);
XACCLogger
::
instance
()
->
info
(
"Plugin Lib Directory: "
+
xaccLibDir
);
for
(
auto
&
entry
:
boost
::
make_iterator_range
(
boost
::
filesystem
::
directory_iterator
(
xaccLibDir
),
{
}))
{
// We want the gate and aqc bundles that come with XACC
if
(
boost
::
contains
(
entry
.
path
().
filename
().
string
(),
"libxacc-quantum"
))
{
XACCLogger
::
instance
()
->
info
(
"Installing plugin "
+
entry
.
path
().
string
());
context
.
InstallBundles
(
entry
.
path
().
string
());
}
}
...
...
@@ -46,6 +41,7 @@ void ServiceRegistry::initialize() {
for
(
auto
&
entry
:
boost
::
make_iterator_range
(
boost
::
filesystem
::
directory_iterator
(
itr
->
path
()),
{
}))
{
XACCLogger
::
instance
()
->
info
(
"Installing plugin "
+
entry
.
path
().
string
());
context
.
InstallBundles
(
entry
.
path
().
string
());
}
}
...
...
@@ -57,25 +53,19 @@ void ServiceRegistry::initialize() {
"There are no plugins. Install plugins to begin working with XACC."
);
}
// Start the framework itself.
framework
.
Start
();
try
{
// Start the framework itself.
framework
.
Start
();
// Our bundles depend on each other in the sense that the consumer
// bundle expects a ServiceTime service in its activator Start()
// function. This is done here for simplicity, but is actually
// bad practice.
auto
bundles
=
context
.
GetBundles
();
for
(
auto
b
:
bundles
)
{
b
.
Start
();
}
initialized
=
true
;
}
catch
(
const
std
::
exception
&
e
)
{
XACCLogger
::
instance
()
->
error
(
"Failure to start XACC plugins. "
+
std
::
string
(
e
.
what
()));
// Our bundles depend on each other in the sense that the consumer
// bundle expects a ServiceTime service in its activator Start()
// function. This is done here for simplicity, but is actually
// bad practice.
auto
bundles
=
context
.
GetBundles
();
for
(
auto
b
:
bundles
)
{
b
.
Start
();
}
initialized
=
true
;
}
}
...
...
xacc/utils/ServiceRegistry.hpp
View file @
19d8426a
...
...
@@ -94,6 +94,7 @@ public:
template
<
typename
ServiceInterface
>
std
::
shared_ptr
<
ServiceInterface
>
getService
(
const
std
::
string
name
)
{
std
::
shared_ptr
<
ServiceInterface
>
ret
;
auto
allServiceRefs
=
context
.
GetServiceReferences
<
ServiceInterface
>
();
for
(
auto
s
:
allServiceRefs
)
{
auto
service
=
context
.
GetService
(
s
);
...
...
@@ -102,14 +103,19 @@ public:
auto
checkCloneable
=
std
::
dynamic_pointer_cast
<
xacc
::
Cloneable
<
ServiceInterface
>>
(
service
);
if
(
checkCloneable
)
{
ret
urn
checkCloneable
->
clone
();
ret
=
checkCloneable
->
clone
();
}
else
{
ret
urn
service
;
ret
=
service
;
}
}
}
XACCLogger
::
instance
()
->
error
(
"Could not find service with name "
+
name
+
". "
"Perhaps the service is not Identifiable."
);
if
(
!
ret
)
{
XACCLogger
::
instance
()
->
error
(
"Could not find service with name "
+
name
+
". "
"Perhaps the service is not Identifiable."
);
}
return
ret
;
}
template
<
typename
ServiceInterface
>
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment