| 156 | } |
| 157 | |
| 158 | void NodeImpl::setParent( NodeImplSharedPtr parent, const ustring &elementName ) |
| 159 | { |
| 160 | // don't checkImageFileOpen |
| 161 | |
| 162 | // First check if our parent_ is already set, throw |
| 163 | // ErrorAlreadyHasParent The isAttached_ condition is to catch two |
| 164 | // errors: |
| 165 | // 1) if user attempts to use the ImageFile root as a child (e.g. |
| 166 | // root.set("x", root)) 2) if user attempts to reuse codecs or prototype |
| 167 | // trees of a CompressedVectorNode |
| 168 | // ??? what if CV not attached yet? |
| 169 | if ( !parent_.expired() || isAttached_ ) |
| 170 | { |
| 171 | // ??? does caller do setParent first, so state is not messed up when |
| 172 | // throw? |
| 173 | throw E57_EXCEPTION2( ErrorAlreadyHasParent, |
| 174 | "this->pathName=" + this->pathName() + |
| 175 | " newParent->pathName=" + parent->pathName() ); |
| 176 | } |
| 177 | |
| 178 | parent_ = parent; |
| 179 | elementName_ = elementName; |
| 180 | |
| 181 | // If parent is attached then we are attached (and all of our children) |
| 182 | if ( parent->isAttached() ) |
| 183 | { |
| 184 | setAttachedRecursive(); |
| 185 | } |
| 186 | } |
| 187 | |
| 188 | NodeImplSharedPtr NodeImpl::getRoot() |
| 189 | { |
no test coverage detected