XdmfGridCollectionType.cpp 3.65 KB
Newer Older
Kenneth Leiter's avatar
Kenneth Leiter committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
/*****************************************************************************/
/*                                    XDMF                                   */
/*                       eXtensible Data Model and Format                    */
/*                                                                           */
/*  Id : XdmfGridCollectionType.cpp                                          */
/*                                                                           */
/*  Author:                                                                  */
/*     Kenneth Leiter                                                        */
/*     kenneth.leiter@arl.army.mil                                           */
/*     US Army Research Laboratory                                           */
/*     Aberdeen Proving Ground, MD                                           */
/*                                                                           */
/*     Copyright @ 2011 US Army Research Laboratory                          */
/*     All Rights Reserved                                                   */
/*     See Copyright.txt for details                                         */
/*                                                                           */
/*     This software is distributed WITHOUT ANY WARRANTY; without            */
/*     even the implied warranty of MERCHANTABILITY or FITNESS               */
/*     FOR A PARTICULAR PURPOSE.  See the above copyright notice             */
/*     for more information.                                                 */
/*                                                                           */
/*****************************************************************************/
23

24
#include <utility>
25
#include "XdmfError.hpp"
26
#include "XdmfGridCollectionType.hpp"
27 28

// Supported XdmfGridCollectionTypes
29
shared_ptr<const XdmfGridCollectionType>
30
XdmfGridCollectionType::NoCollectionType()
31
{
32
  static shared_ptr<const XdmfGridCollectionType>
33 34
    p(new XdmfGridCollectionType("None"));
  return p;
35 36
}

37
shared_ptr<const XdmfGridCollectionType>
38
XdmfGridCollectionType::Spatial()
39
{
40
  static shared_ptr<const XdmfGridCollectionType>
41 42
    p(new XdmfGridCollectionType("Spatial"));
  return p;
43 44
}

45
shared_ptr<const XdmfGridCollectionType>
46
XdmfGridCollectionType::Temporal()
47
{
48
  static shared_ptr<const XdmfGridCollectionType>
49 50
    p(new XdmfGridCollectionType("Temporal"));
  return p;
51 52 53
}

XdmfGridCollectionType::XdmfGridCollectionType(const std::string & name) :
54
  mName(name)
55 56 57
{
}

58 59 60 61
XdmfGridCollectionType::~XdmfGridCollectionType()
{
}

62
shared_ptr<const XdmfGridCollectionType>
63
XdmfGridCollectionType::New(const std::map<std::string, std::string> & itemProperties)
64
{
65 66
  std::map<std::string, std::string>::const_iterator type =
    itemProperties.find("CollectionType");
67
  if(type == itemProperties.end()) {
68 69 70
    XdmfError::message(XdmfError::FATAL, 
                       "'CollectionType' not in itemProperties in "
                       "XdmfGridCollectionType::New");
71 72 73 74 75
  }

  const std::string & typeVal = type->second;
  if(typeVal.compare("None") == 0) {
    return NoCollectionType();
76
  }
77 78 79 80 81 82 83
  else if(typeVal.compare("Spatial") == 0) {
    return Spatial();
  }
  else if(typeVal.compare("Temporal") == 0) {
    return Temporal();
  }

84 85 86
  XdmfError::message(XdmfError::FATAL, 
                     "'CollectionType' not of 'None', 'Spatial', or "
                     "'Temporal' in XdmfGridCollectionType::New");
87

88
  // unreachable
89
  return shared_ptr<const XdmfGridCollectionType>();
90 91
}

92 93
void
XdmfGridCollectionType::getProperties(std::map<std::string, std::string> & collectedProperties) const
94
{
95
  collectedProperties.insert(std::make_pair("CollectionType", mName));
96
}