Skip to content
Snippets Groups Projects
Commit 51510e3f authored by Markus FRANK's avatar Markus FRANK Committed by MarkusFrankATcernch
Browse files

Support for conditions with non-default ctor

parent f6a5228f
No related branches found
No related tags found
No related merge requests found
...@@ -122,6 +122,8 @@ namespace dd4hep { ...@@ -122,6 +122,8 @@ namespace dd4hep {
void* bind(const BasicGrammar* grammar); void* bind(const BasicGrammar* grammar);
/// Bind data value in place /// Bind data value in place
void* bind(void* ptr, size_t len, const BasicGrammar* grammar); void* bind(void* ptr, size_t len, const BasicGrammar* grammar);
/// Bind external data value to the pointer
void bindExtern(void* ptr, const BasicGrammar* grammar);
/// Construct conditions object and bind the data /// Construct conditions object and bind the data
template <typename T, typename... Args> T& construct(Args... args); template <typename T, typename... Args> T& construct(Args... args);
/// Bind data value /// Bind data value
...@@ -132,6 +134,8 @@ namespace dd4hep { ...@@ -132,6 +134,8 @@ namespace dd4hep {
template <typename T> T& bind(const std::string& value); template <typename T> T& bind(const std::string& value);
/// Bind data value /// Bind data value
template <typename T> T& bind(void* ptr, size_t len, const std::string& value); template <typename T> T& bind(void* ptr, size_t len, const std::string& value);
/// Bind external data value to the pointer
template <typename T> void bindExtern(T* ptr);
}; };
/// Generic getter. Specify the exact type, not a polymorph type /// Generic getter. Specify the exact type, not a polymorph type
...@@ -183,5 +187,10 @@ namespace dd4hep { ...@@ -183,5 +187,10 @@ namespace dd4hep {
} }
return ret; return ret;
} }
/// Bind external data value to the pointer
template <typename T> void OpaqueDataBlock::bindExtern(T* ptr) {
bindExtern(ptr, &BasicGrammar::instance<T>());
}
} /* End namespace dd4hep */ } /* End namespace dd4hep */
#endif /* DD4HEP_OPAQUEDATA_H */ #endif /* DD4HEP_OPAQUEDATA_H */
...@@ -143,6 +143,18 @@ void* OpaqueDataBlock::bind(const BasicGrammar* g) { ...@@ -143,6 +143,18 @@ void* OpaqueDataBlock::bind(const BasicGrammar* g) {
return 0; return 0;
} }
/// Bind external data value to the pointer
void OpaqueDataBlock::bindExtern(void* ptr, const BasicGrammar* gr) {
if ( grammar != 0 && type != EXTERN_DATA ) {
// We cannot ingore secondary requests for data bindings.
// This leads to memory leaks in the caller!
except("OpaqueData","You may not bind opaque data multiple times!");
}
pointer = ptr;
grammar = gr;
type = EXTERN_DATA;
}
/// Set data value /// Set data value
void* OpaqueDataBlock::bind(void* ptr, size_t size, const BasicGrammar* g) { void* OpaqueDataBlock::bind(void* ptr, size_t size, const BasicGrammar* g) {
if ( (type&EXTERN_DATA) == EXTERN_DATA ) { if ( (type&EXTERN_DATA) == EXTERN_DATA ) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment