1 /*******************************************************************/
2 /*                               XDMF                              */
3 /*                   eXtensible Data Model and Format              */
4 /*                                                                 */
5 /*  Id : Id  */
6 /*  Date : $Date$ */
7 /*  Version : $Revision$ */
8 /*                                                                 */
9 /*  Author:                                                        */
10 /*     Jerry A. Clarke                                             */
11 /*     clarke@arl.army.mil                                         */
12 /*     US Army Research Laboratory                                 */
13 /*     Aberdeen Proving Ground, MD                                 */
14 /*                                                                 */
15 /*     Copyright @ 2002 US Army Research Laboratory                */
16 /*     All Rights Reserved                                         */
17 /*     See Copyright.txt or http://www.arl.hpc.mil/ice for details */
18 /*                                                                 */
19 /*     This software is distributed WITHOUT ANY WARRANTY; without  */
20 /*     even the implied warranty of MERCHANTABILITY or FITNESS     */
21 /*     FOR A PARTICULAR PURPOSE.  See the above copyright notice   */
22 /*     for more information.                                       */
23 /*                                                                 */
24 /*******************************************************************/
25 #ifndef __XdmfTime_h
26 #define __XdmfTime_h
27 
28 //! Define time for Grid
29 /*! XdmfTime represents a Time specification.
30 Time is a child of the <Grid> element :
31 \verbatim
32 <Time TypeType="Single* | List | HyperSlab | Range | Function"
33     NumberOfIterations="1* | N"
34     Value="(no default)">
35      <DataItem ....
36 </Time>
37     TimeType can be :
38         Single - A Single Time for the entire Grid
39         List - a Time Series
40         HyperSlab - Start Stride Count
41         Range - Min Max
42         Function - XdmfFloat64 *Function(GridIndex)
43 \endverbatim
44 */
45 
46 #include "XdmfElement.h"
47 
48 namespace xdmf2
49 {
50 
51 class XdmfDataItem;
52 class XdmfArray;
53 class XdmfGrid;
54 
55 #define XDMF_TIME_SINGLE    0x00
56 #define XDMF_TIME_LIST      0x01
57 #define XDMF_TIME_HYPERSLAB 0x02
58 #define XDMF_TIME_RANGE     0x03
59 #define XDMF_TIME_FUNCTION  0x04
60 #define XDMF_TIME_UNSET     0x0FF
61 
62 class XDMF_EXPORT XdmfTime : public XdmfElement {
63 
64 public:
65   XdmfTime();
66   virtual ~XdmfTime();
67 
GetClassName()68   XdmfConstString GetClassName() { return ( "XdmfTime" ) ; };
69 
70 //! Insert an Element
71   XdmfInt32 Insert (XdmfElement *Child);
72 //! Update From XML
73     XdmfInt32 UpdateInformation();
74 
75 /*! Set the internal value. This is not reflected in the DOM
76     Until Build() is called.
77 */
78     XdmfSetValueMacro(Value, XdmfFloat64);
79 
80 //! Update the DOM
81     XdmfInt32 Build();
82 
83 /*! Get the internal Value.
84 */
85     XdmfGetValueMacro(Value, XdmfFloat64);
86     //! Get the Array
87     XdmfGetValueMacro(Array, XdmfArray *);
88     //! Set the Array
89     XdmfSetValueMacro(Array, XdmfArray *);
90     //! Get the Array
91     XdmfGetValueMacro(DataItem, XdmfDataItem *);
92     //! Set the DataItem
93     XdmfSetValueMacro(DataItem, XdmfDataItem *);
94     //! Get the Type
95     XdmfGetValueMacro(TimeType, XdmfInt32);
96     //! Get the Type as a String
97     XdmfConstString GetTimeTypeAsString(void);
98     //! Set the Type
99     XdmfSetValueMacro(TimeType, XdmfInt32);
100     //! Get the Function
101     XdmfGetStringMacro(Function);
102     //! Set the Function
103     XdmfSetStringMacro(Function);
104     //! Set Time From Parent Information
105     XdmfInt32 SetTimeFromParent(XdmfTime *ParentTime, XdmfInt64 Index);
106     //! Fills in the sets of times that a particular grid is valid.
107     XdmfInt32 Evaluate(XdmfGrid *Grid, XdmfArray *ArrayToFill = NULL, XdmfInt32 Descend = 0, XdmfInt32 Append = 0);
108     //! Is Time Valid at Specified Value
109     XdmfInt32 IsValid(XdmfTime *TimeSpec);
110     //! Is Time within Range
111     XdmfInt32 IsValid(XdmfFloat64 TimeMin, XdmfFloat64 TimeMax);
112     //! Set the Epsilon used for Floating Point comparison (1e-7)
113     XdmfSetValueMacro(Epsilon, XdmfFloat64);
114     //! Get the Epsilon used for Floating Point comparison (1e-7)
115     XdmfGetValueMacro(Epsilon, XdmfFloat64);
116 protected:
117     XdmfInt32    TimeType;
118     XdmfFloat64  Value;
119     XdmfFloat64  Epsilon;
120     XdmfArray    *Array;
121     XdmfDataItem *DataItem;
122     XdmfString   Function;
123 };
124 }
125 #endif // __XdmfTime_h
126