XdmfSetType.cpp 3.8 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 : XdmfSetType.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 "XdmfSetType.hpp"
25
#include "XdmfError.hpp"
26 27

// Supported XdmfSetTypes
28
shared_ptr<const XdmfSetType>
29
XdmfSetType::NoSetType()
30
{
31
  static shared_ptr<const XdmfSetType> p(new XdmfSetType("None"));
32
  return p;
33 34
}

35
shared_ptr<const XdmfSetType>
36
XdmfSetType::Node()
37
{
38
  static shared_ptr<const XdmfSetType> p(new XdmfSetType("Node"));
39
  return p;
40 41
}

42
shared_ptr<const XdmfSetType>
43
XdmfSetType::Cell()
44
{
45
  static shared_ptr<const XdmfSetType> p(new XdmfSetType("Cell"));
46
  return p;
47 48
}

49
shared_ptr<const XdmfSetType>
50
XdmfSetType::Face()
51
{
52
  static shared_ptr<const XdmfSetType> p(new XdmfSetType("Face"));
53
  return p;
54 55
}

56
shared_ptr<const XdmfSetType>
57
XdmfSetType::Edge()
58
{
59
  static shared_ptr<const XdmfSetType> p(new XdmfSetType("Edge"));
60
  return p;
61 62 63
}

XdmfSetType::XdmfSetType(const std::string & name) :
64
  mName(name)
65 66 67
{
}

68 69 70 71
XdmfSetType::~XdmfSetType()
{
}

72
shared_ptr<const XdmfSetType>
73
XdmfSetType::New(const std::map<std::string, std::string> & itemProperties)
74
{
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
  std::map<std::string, std::string>::const_iterator type =
    itemProperties.find("Type");
  if(type == itemProperties.end()) {
    type = itemProperties.find("SetType");
  }
  if(type != itemProperties.end()) {
    const std::string typeVal = type->second;
    if(typeVal.compare("None") == 0) {
      return NoSetType();
    }
    else if(typeVal.compare("Node") == 0) {
      return Node();
    }
    else if(typeVal.compare("Cell") == 0) {
      return Cell();
    }
    else if(typeVal.compare("Face") == 0) {
      return Face();
    }
    else if(typeVal.compare("Edge") == 0) {
      return Edge();
    }
    else {
98 99 100
      XdmfError::message(XdmfError::FATAL, 
                         "Type not of 'None', 'Node', 'Cell', 'Face', or "
                         "'Edge' in XdmfSetType::New");
101 102
    }
  }
103 104 105 106
  XdmfError::message(XdmfError::FATAL, 
                     "Neither 'Type' nor 'SetType' found in itemProperties "
                     "in XdmfSetType::New");
  return shared_ptr<const XdmfSetType>();
107 108
}

109 110
void
XdmfSetType::getProperties(std::map<std::string, std::string> & collectedProperties) const
111
{
112
  collectedProperties["Type"] = this->mName;
113
}