19 #define DATASVC_DATASVC_CPP
45 inline std::string itemToPath(
int item) {
46 std::ostringstream
path;
57 #define CAST_REGENTRY(x,y) dynamic_cast<x>(y)
61 #define ON_DEBUG if (UNLIKELY(outputLevel() <= MSG::DEBUG))
62 #define ON_VERBOSE if (UNLIKELY(outputLevel() <= MSG::VERBOSE))
64 #define DEBMSG ON_DEBUG debug()
65 #define VERMSG ON_VERBOSE verbose()
75 if ( 0 != node_entry ) {
78 parent->
remove(node_entry);
81 return INVALID_PARENT;
83 return INVALID_OBJECT;
100 return INVALID_PARENT;
102 return INVALID_OBJECT;
138 return INVALID_OBJECT;
168 if ( 0 != pRootObj ) {
194 if ( 0 != pRootAddr ) {
205 if ( 0 != pDataLoader ) pDataLoader->
addRef();
207 if ( 0 != pDataLoader ) {
220 return INVALID_OBJECT;
228 refpParent = node_entry->
parent();
231 return INVALID_OBJECT;
238 std::vector<IRegistry*>& leaves) {
242 return INVALID_OBJECT;
249 std::vector<IRegistry*>& leaves) {
253 leaves = node_entry->
leaves();
256 return INVALID_OBJECT;
264 if ( fullPath.length() > 0 ) {
271 return INVALID_OBJ_PATH;
276 const std::string& objectPath,
284 const std::string& objPath,
287 if ( objPath.length() > 0 ) {
288 if ( 0 == parentObj ) {
292 std::string::size_type sep = objPath.find(
SEPARATOR,1);
293 if ( sep != std::string::npos ) {
294 std::string p_path (objPath, 0, sep);
296 std::string o_path (objPath, sep, objPath.length());
300 return INVALID_PARENT;
309 if ( 0 != par_entry ) {
310 std::string::size_type sep = objPath.rfind(
SEPARATOR);
311 if ( sep > 0 && sep != std::string::npos ) {
312 std::string p_path (objPath, 0, sep);
313 std::string o_path (objPath, sep, objPath.length());
325 p_entry = par_entry->
findLeaf(p_path);
327 if ( 0 != p_entry ) {
330 return INVALID_PARENT;
336 return DOUBL_OBJ_PATH;
338 return INVALID_PARENT;
340 return INVALID_OBJ_PATH;
347 if ( fullPath.length() > 0 ) {
354 return INVALID_OBJ_PATH;
359 const std::string& objPath) {
366 const std::string& objPath) {
368 if ( objPath.length() > 0 ) {
369 if ( 0 == pParent ) {
373 std::string::size_type sep = objPath.find(
SEPARATOR,1);
374 if ( sep != std::string::npos ) {
375 std::string p_path (objPath, 0, sep);
377 std::string o_path (objPath, sep, objPath.length());
381 return INVALID_PARENT;
390 if ( 0 != node_entry ) {
392 if ( 0 != leaf_entry ) {
393 std::string::size_type sep = objPath.rfind(
SEPARATOR);
394 if ( sep > 0 && sep != std::string::npos ) {
395 std::string
path = objPath.substr(sep);
404 return INVALID_PARENT;
406 return INVALID_OBJ_PATH;
420 const std::string& objPath,
453 const std::string& objPath,
456 if ( 0 == parentObj ) {
457 if ( objPath.length() > 0 ) {
459 std::string::size_type sep = objPath.find(
SEPARATOR,1);
460 if ( sep != std::string::npos ) {
461 std::string p_path (objPath, 0, sep);
462 std::string o_path (objPath, sep, objPath.length());
470 return INVALID_OBJ_PATH;
473 if ( 0 != node_entry ) {
475 std::string::size_type sep = objPath.find(
SEPARATOR,1);
476 if ( sep != std::string::npos ) {
477 std::string p_path (objPath, 0, sep);
478 std::string o_path (objPath, sep, objPath.length());
488 par_entry = node_entry->
findLeaf(p_path);
490 else if ( 0 != par_entry && par_entry->object() == 0 ) {
498 par_entry = node_entry->
findLeaf(p_path);
501 node_entry = par_entry;
502 if ( 0 != node_entry ) {
512 status = node_entry->
add( objPath, pObject );
518 error() <<
"registerObject: trying to register null DataObject" <<
endmsg;
529 status = DOUBL_OBJ_PATH;
535 return INVALID_PARENT;
549 if ( 0 != pParent ) {
550 if ( 0 != pObject ) {
556 return INVALID_PARENT;
558 return DIR_NOT_EMPTY;
567 const std::string& objPath) {
589 if ( 0 != entry->
object() ) {
597 return INVALID_PARENT;
599 return DIR_NOT_EMPTY;
601 return INVALID_OBJECT;
608 const std::string& objectPath) {
616 if ( 0 != entry->
object() ) {
622 return DIR_NOT_EMPTY;
624 return INVALID_OBJECT;
629 return INVALID_PARENT;
645 if ( pReg && path.length() == 0 ) {
687 if ( 0 == pLoader ) {
689 else return NO_DATA_LOADER;
691 if ( 0 == pRegistry ) {
693 else return INVALID_OBJ_ADDR;
704 const std::string& ident = pRegistry->
identifier();
705 std::vector<std::string>::iterator inhibit =
712 if ( 0 == pAddress ) {
713 return INVALID_OBJ_ADDR;
716 status = pLoader->
createObj(pAddress, pObject);
735 catch(
const std::exception& x) {
763 const std::string&
path,
765 std::string::size_type sep = path.find(
SEPARATOR,1);
770 if ( 0 == parentObj ) {
771 if ( path.length() == 0 || path ==
m_rootName ) {
777 else if ( sep != std::string::npos ) {
785 std::string o_path (path, sep, path.length());
788 return INVALID_OBJ_PATH;
790 if ( sep != std::string::npos ) {
791 std::string p_path (path,0,sep);
792 std::string o_path (path,sep,path.length());
793 if (!parentObj->
object()) {
804 root_entry = parentObj->
findLeaf(p_path);
815 if ( root_entry->
isSoft() ) {
822 else if ( path.length() == 0 ) {
826 if (!parentObj->
object()) {
837 pEntry = (0==path.length()) ? parentObj : parentObj->
findLeaf(path);
842 status = INVALID_OBJ_PATH;
844 else if ( 0 == pEntry->
object() ) {
865 const std::string&
path,
871 pObject = result->
object();
885 const std::string& objectPath,
904 const std::string&
path,
919 const std::string&
path,
924 if ( 0 != root_entry ) {
925 if ( path.length() > 0 ) {
926 pReg = root_entry->
find(path);
929 return INVALID_OBJ_PATH;
933 return (0 == pObject) ? OBJ_NOT_LOADED : IDataProviderSvc_NO_ERROR;
941 if ( path.length() == 0 || path ==
m_rootName ) {
943 return (0 == pObject) ? OBJ_NOT_LOADED : IDataProviderSvc_NO_ERROR;
955 const std::string& objectPath,
960 status =
findObject (parent, objectPath, pObject);
968 return findObject(parentPath, itemToPath(item), pObject);
975 return findObject(parentObj, itemToPath(item), pObject);
980 const std::string&
path,
998 if ( 0 == pRegistry ) {
999 return INVALID_OBJ_ADDR;
1002 if ( 0 == toUpdate ) {
1011 if ( 0 == toUpdate ) {
1012 return INVALID_OBJECT;
1015 if ( 0 == pRegistry ) {
1016 return INVALID_OBJECT;
1019 if ( 0 == pAddress ) {
1020 return INVALID_OBJ_ADDR;
1023 if ( 0 == pLoader ) {
1024 return NO_DATA_LOADER;
1027 const std::string& ident = pRegistry->
identifier();
1028 std::vector<std::string>::iterator inhibit =
1035 status = pLoader->
updateObj(pAddress, toUpdate);
1046 catch(
const std::exception& x) {
1048 pRegistry->
name() +
": " +
1063 const std::string& updatePath) {
1074 const std::string& updatePath) {
1085 const std::string& objPath,
DataObject* to) {
1089 if ( 0 != from_entry ) {
1092 if ( 0 == to_entry ) {
1093 return INVALID_OBJECT;
1096 std::string::size_type sep = objPath.rfind(
SEPARATOR);
1097 if ( sep > 0 && sep != std::string::npos ) {
1099 std::string fromPath(objPath, 0, sep);
1102 std::string toPath(objPath, sep, objPath.length());
1110 IDataProviderSvc_NO_ERROR : DOUBL_OBJ_PATH;
1116 return INVALID_PARENT;
1118 return INVALID_ROOT;
1124 if ( fullPath.length() > 0 ) {
1128 std::string::size_type sep = fullPath.rfind(
SEPARATOR);
1129 std::string objPath(fullPath, sep, fullPath.length());
1130 std::string fromPath(fullPath, 0, sep);
1133 return INVALID_OBJ_PATH;
1138 const std::string& objPath,
1150 const std::string& objPath,
1154 if ( 0 != from_entry ) {
1158 return INVALID_PARENT;
1163 const std::string& objPath) {
1167 if ( 0 != from_entry ) {
1168 std::string::size_type sep = objPath.rfind(
SEPARATOR);
1169 if ( sep > 0 && sep != std::string::npos ) {
1171 std::string fromPath(objPath, 0, sep);
1174 std::string toPath(objPath, sep, objPath.length());
1183 return INVALID_OBJ_PATH;
1188 return INVALID_PARENT;
1190 return INVALID_ROOT;
1195 if ( fullPath.length() > 0 ) {
1199 std::string::size_type sep = fullPath.rfind(
SEPARATOR);
1200 std::string objPath(fullPath, sep, fullPath.length());
1201 std::string fromPath(fullPath, 0, sep);
1204 return INVALID_OBJ_PATH;
1209 const std::string& objPath) {
1220 const std::string& objPath) {
1225 return INVALID_ROOT;
1244 LoadItems::iterator
i =
1266 if ( 0 != pObject && depth++ < load_depth ) {
1272 if ( status.
isSuccess() && depth < load_depth ) {
1286 int load_depth = (*i).depth();
1287 if ( sc.
isSuccess() && load_depth > 1 ) {
1303 error() <<
"Failed to access incident service." <<
endmsg;
1322 error() <<
"Unable to reinitialize base class" <<
endmsg;
1328 error() <<
"Failed to access incident service." <<
endmsg;
1373 m_rootName(
"/Event"), m_root(0)