| 318 | } |
| 319 | |
| 320 | std::shared_ptr<CompressedVectorReaderImpl> CompressedVectorNodeImpl::reader( |
| 321 | std::vector<SourceDestBuffer> dbufs ) |
| 322 | { |
| 323 | checkImageFileOpen( __FILE__, __LINE__, static_cast<const char *>( __FUNCTION__ ) ); |
| 324 | |
| 325 | ImageFileImplSharedPtr destImageFile( destImageFile_ ); |
| 326 | |
| 327 | // Check don't have any writers/readers open for this ImageFile |
| 328 | if ( destImageFile->writerCount() > 0 ) |
| 329 | { |
| 330 | throw E57_EXCEPTION2( ErrorTooManyWriters, |
| 331 | "fileName=" + destImageFile->fileName() + |
| 332 | " writerCount=" + toString( destImageFile->writerCount() ) + |
| 333 | " readerCount=" + toString( destImageFile->readerCount() ) ); |
| 334 | } |
| 335 | if ( destImageFile->readerCount() > 0 ) |
| 336 | { |
| 337 | throw E57_EXCEPTION2( ErrorTooManyReaders, |
| 338 | "fileName=" + destImageFile->fileName() + |
| 339 | " writerCount=" + toString( destImageFile->writerCount() ) + |
| 340 | " readerCount=" + toString( destImageFile->readerCount() ) ); |
| 341 | } |
| 342 | |
| 343 | // dbufs can't be empty |
| 344 | if ( dbufs.empty() ) |
| 345 | { |
| 346 | throw E57_EXCEPTION2( ErrorBadAPIArgument, "fileName=" + destImageFile->fileName() ); |
| 347 | } |
| 348 | |
| 349 | // Can be read or write mode, but must be attached |
| 350 | if ( !isAttached() ) |
| 351 | { |
| 352 | throw E57_EXCEPTION2( ErrorNodeUnattached, "fileName=" + destImageFile->fileName() ); |
| 353 | } |
| 354 | |
| 355 | // Get pointer to me (really shared_ptr<CompressedVectorNodeImpl>) |
| 356 | NodeImplSharedPtr ni( shared_from_this() ); |
| 357 | #ifdef E57_VERBOSE |
| 358 | // cout << "constructing CAReader, ni:" << std::endl; |
| 359 | // ni->dump(4); |
| 360 | #endif |
| 361 | |
| 362 | // Downcast pointer to right type |
| 363 | std::shared_ptr<CompressedVectorNodeImpl> cai( |
| 364 | std::static_pointer_cast<CompressedVectorNodeImpl>( ni ) ); |
| 365 | #ifdef E57_VERBOSE |
| 366 | // cout<<"constructing CAReader, cai:"<<endl; |
| 367 | // cai->dump(4); |
| 368 | #endif |
| 369 | // Return a shared_ptr to new object |
| 370 | std::shared_ptr<CompressedVectorReaderImpl> cvri( |
| 371 | new CompressedVectorReaderImpl( cai, dbufs ) ); |
| 372 | return ( cvri ); |
| 373 | } |
| 374 | } |
nothing calls this directly
no test coverage detected