XdmfGridCollectionType.cpp 3.63 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 "XdmfGridCollectionType.hpp"
25
#include "XdmfError.hpp"
26 27

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

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

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

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

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

61
shared_ptr<const XdmfGridCollectionType>
62
XdmfGridCollectionType::New(const std::map<std::string, std::string> & itemProperties)
63
{
64 65 66 67 68 69 70 71 72 73 74 75 76 77
  std::map<std::string, std::string>::const_iterator type =
    itemProperties.find("CollectionType");
  if(type != itemProperties.end()) {
    const std::string typeVal = type->second;
    if(typeVal.compare("None") == 0) {
      return NoCollectionType();
    }
    else if(typeVal.compare("Spatial") == 0) {
      return Spatial();
    }
    else if(typeVal.compare("Temporal") == 0) {
      return Temporal();
    }
    else {
78 79 80
      XdmfError::message(XdmfError::FATAL, 
                         "'CollectionType' not of 'None', 'Spatial', or "
                         "'Temporal' in XdmfGridCollectionType::New");
81 82
    }
  }
83 84 85 86
  XdmfError::message(XdmfError::FATAL, 
                     "'CollectionType' not in itemProperties in "
                     "XdmfGridCollectionType::New");
  return shared_ptr<const XdmfGridCollectionType>();
87 88
}

89 90
void
XdmfGridCollectionType::getProperties(std::map<std::string, std::string> & collectedProperties) const
91
{
92
  collectedProperties["CollectionType"] = mName;
93
}