-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathXdmfTime.cpp
More file actions
124 lines (108 loc) · 3.74 KB
/
Copy pathXdmfTime.cpp
File metadata and controls
124 lines (108 loc) · 3.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
/*****************************************************************************/
/* XDMF */
/* eXtensible Data Model and Format */
/* */
/* Id : XdmfTime.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. */
/* */
/*****************************************************************************/
#include <sstream>
#include <utility>
#include "XdmfTime.hpp"
#include "XdmfError.hpp"
shared_ptr<XdmfTime>
XdmfTime::New(const double & value)
{
shared_ptr<XdmfTime> p(new XdmfTime(value));
return p;
}
XdmfTime::XdmfTime(const double & value) :
mValue(value)
{
}
XdmfTime::XdmfTime(XdmfTime & refTime) :
XdmfItem(refTime),
mValue(refTime.getValue())
{
}
XdmfTime::~XdmfTime()
{
}
const std::string XdmfTime::ItemTag = "Time";
std::map<std::string, std::string>
XdmfTime::getItemProperties() const
{
std::map<std::string, std::string> timeProperties;
std::stringstream value;
value << mValue;
timeProperties.insert(std::make_pair("Value", value.str()));
return timeProperties;
}
std::string
XdmfTime::getItemTag() const
{
return ItemTag;
}
double
XdmfTime::getValue() const
{
return mValue;
}
void
XdmfTime::populateItem(const std::map<std::string, std::string> & itemProperties,
const std::vector<shared_ptr<XdmfItem> > & childItems,
const XdmfCoreReader * const reader)
{
XdmfItem::populateItem(itemProperties, childItems, reader);
std::map<std::string, std::string>::const_iterator value =
itemProperties.find("Value");
if(value != itemProperties.end()) {
mValue = atof(value->second.c_str());
}
else {
XdmfError::message(XdmfError::FATAL,
"'Value' not in itemProperties in "
"XdmfTime::populateItem");
}
}
void
XdmfTime::setValue(const double & value)
{
mValue = value;
this->setIsChanged(true);
}
// C Wrappers
XDMFTIME * XdmfTimeNew(double value)
{
try
{
return (XDMFTIME *)((void *)(new XdmfTime(*(XdmfTime::New(value).get()))));
}
catch (...)
{
return (XDMFTIME *)((void *)(new XdmfTime(*(XdmfTime::New(value).get()))));
}
}
double XdmfTimeGetValue(XDMFTIME * timePointer)
{
return ((XdmfTime *)timePointer)->getValue();
}
void XdmfTimeSetValue(XDMFTIME * timePointer, double time)
{
((XdmfTime *)timePointer)->setValue(time);
}
XDMF_ITEM_C_CHILD_WRAPPER(XdmfTime, XDMFTIME)