forked from perabrahamsen/daisy-model
-
Notifications
You must be signed in to change notification settings - Fork 0
/
attribute.h
99 lines (89 loc) · 3.27 KB
/
attribute.h
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
// attribute.h -- Type system for attributes.
//
// Copyright 1996-2001 Per Abrahamsen and Søren Hansen
// Copyright 2000-2001 KVL.
// Copyright 2008 Per Abrahamsen and KVL.
//
// This file is part of Daisy.
//
// Daisy is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// Daisy is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser Public License for more details.
//
// You should have received a copy of the GNU Lesser Public License
// along with Daisy; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#ifndef ATTRIBUTE_H
#define ATTRIBUTE_H
#include "symbol.h"
#ifdef __unix
#define EXPORT /* Nothing */
#elif defined (BUILD_DLL)
/* DLL export */
#define EXPORT __declspec(dllexport)
#else
/* EXE import */
#define EXPORT __declspec(dllimport)
#endif
namespace Attribute
{
// A attribute entry has an associated size. If the size is a positive
// integer, the attribute entry specifies an array of that size. The
// default size 'Singleton' indicating that the attribute entry match a
// single item of the specified type, while the 'Variable' used for
// entries that contain an array of unspecified length.
const int Singleton = -117;
const int Variable = -3210;
const int CanopyCells = -3211;
const int CanopyEdges = -3212;
const int SoilCells = -3213;
const int SoilEdges = -3214;
const int Unspecified = -666;
symbol size_name (int);
// Size is not known at compile time.
inline bool flexible_size (const int size)
{ return size == Variable || size == CanopyCells || size == CanopyEdges
|| size == SoilCells || size == SoilEdges; }
// A attribute may have a dimension associated.
symbol Unknown ();
EXPORT symbol None ();
symbol Fraction ();
symbol User ();
// Each attribute entry should have an associated type.
enum type
{ Number, Submodel, PLF, Boolean, String,
Integer, Model, Scalar, Reference, Error };
EXPORT symbol type_name (type);
type type_number (symbol name);
// The requirements with regard to input and output varies with each
// attribute entry.
enum category
{
// This is a parameter, i.e. its attribute doesn't change during the
// compilation, and it cannot be written to the log.
Const,
// This a state variable, it must be provided at initialization
// and can be written to the log.
State,
// This is a state variable that can be computed from other
// parameters or state variables, and therefore does not need to
// be specified before the simulation starts.
OptionalState,
// This is a parameter that can be computer from other parameters,
// and therefore does not need to be specified before
// the simulation starts.
OptionalConst,
// This is a variable that is only computed for logging purposes
// and not a part of the simulation state.
LogOnly
};
symbol category_name (category);
int category_number (symbol name);
}
#endif // ATTRIBUTE_H