Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions

mitk::BaseDataIO Class Reference
[IO Classes]

BaseDataIO creates instances of BaseData objects using an object factory. More...

#include <mitkBaseDataIOFactory.h>

List of all members.

Public Types

typedef BaseDataIO Self
typedef itk::Object Superclass
typedef itk::SmartPointer< SelfPointer
typedef itk::SmartPointer
< const Self
ConstPointer

Public Member Functions

virtual const char * GetClassName () const

Static Public Member Functions

static std::vector
< mitk::BaseData::Pointer
LoadBaseDataFromFile (const std::string path, const std::string filePrefix, const std::string filePattern, bool series)

Protected Member Functions

 BaseDataIO ()
 ~BaseDataIO ()

Detailed Description

BaseDataIO creates instances of BaseData objects using an object factory.

Definition at line 34 of file mitkBaseDataIOFactory.h.


Member Typedef Documentation

typedef itk::SmartPointer<const Self> mitk::BaseDataIO::ConstPointer

Definition at line 42 of file mitkBaseDataIOFactory.h.

typedef itk::SmartPointer<Self> mitk::BaseDataIO::Pointer

Definition at line 41 of file mitkBaseDataIOFactory.h.

Standard class typedefs.

Definition at line 39 of file mitkBaseDataIOFactory.h.

typedef itk::Object mitk::BaseDataIO::Superclass

Definition at line 40 of file mitkBaseDataIOFactory.h.


Constructor & Destructor Documentation

mitk::BaseDataIO::BaseDataIO (  ) [protected]
mitk::BaseDataIO::~BaseDataIO (  ) [protected]

Member Function Documentation

virtual const char* mitk::BaseDataIO::GetClassName (  ) const [virtual]

Class Methods used to interface with the registered factories Run-time type information (and related methods).

std::vector< BaseData::Pointer > mitk::BaseDataIO::LoadBaseDataFromFile ( const std::string  path,
const std::string  filePrefix,
const std::string  filePattern,
bool  series 
) [static]

Create the appropriate BaseData depending on the particulars of the file.

Definition at line 27 of file mitkBaseDataIOFactory.cpp.

References MITK_ERROR.

Referenced by mitk::DataNodeFactory::GenerateData().

{

std::vector<BaseData::Pointer> BaseDataIO::LoadBaseDataFromFile(const std::string path, const std::string filePrefix, const std::string filePattern, bool series)
{

  // factories are instantiated in mitk::CoreObjectFactory and other, potentially MITK external places

  std::vector<BaseData::Pointer> result;

  std::list<IOAdapterBase::Pointer> possibleIOAdapter;
  std::list<LightObject::Pointer> allobjects = itk::ObjectFactoryBase::CreateAllInstance("mitkIOAdapter");

  for( std::list<LightObject::Pointer>::iterator i = allobjects.begin();
                                                 i != allobjects.end(); 
                                                 ++i)
  {
    IOAdapterBase* io = dynamic_cast<IOAdapterBase*>(i->GetPointer());
    if(io)
    {
      possibleIOAdapter.push_back(io);
    }
    else
    {
      MITK_ERROR << "Error BaseDataIO factory did not return an IOAdapterBase: "
        << (*i)->GetNameOfClass() 
        << std::endl;
    }
  }

  for( std::list<IOAdapterBase::Pointer>::iterator k = possibleIOAdapter.begin();
                                                   k != possibleIOAdapter.end(); 
                                                   ++k )
  { 
    bool canReadFile = false;
    
    if ( series )
      canReadFile = (*k)->CanReadFile(filePrefix, filePrefix, filePattern); // we have to provide a filename without extension here to 
    else                                                                    // prevent the "normal" (non-series) readers to report that
      canReadFile = (*k)->CanReadFile(path, filePrefix, filePattern);       // they could read the file
    
    if( canReadFile )
    {
      BaseProcess::Pointer ioObject = (*k)->CreateIOProcessObject(path, filePrefix, filePattern);
      ioObject->Update();
      int numberOfContents = static_cast<int>(ioObject->GetNumberOfOutputs());
      
      if (numberOfContents > 0)
      {
        BaseData::Pointer baseData;
        for(int i=0; i<numberOfContents; ++i)
        {
          baseData = dynamic_cast<BaseData*>(ioObject->GetOutputs()[i].GetPointer());
          if (baseData) // this is what's wanted, right?
          {
            result.push_back( baseData );
          }
        }
      }

      break;
    }
  }

The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines