1 |
#ifndef ASCXX_DIMENSIONS_H |
2 |
#define ASCXX_DIMENSIONS_H |
3 |
|
4 |
#include <string> |
5 |
|
6 |
#include "units.h" |
7 |
#include "config.h" |
8 |
|
9 |
extern "C"{ |
10 |
#include <ascend/general/platform.h> |
11 |
#include <ascend/compiler/dimen.h> |
12 |
} |
13 |
|
14 |
/** |
15 |
A mapping of dimensions to units |
16 |
*/ |
17 |
/* |
18 |
map<Dimensions,UnitsM> defaultUnits |
19 |
multimaps<Dimensions,UnitsM> allUnits |
20 |
*/ |
21 |
|
22 |
/** |
23 |
A 'dimensions object'. This is a wrapper to the 'dim_type' in ASCEND. |
24 |
This object allows querying to find suitable units for outputting |
25 |
or inputting data from/for a given type. |
26 |
*/ |
27 |
class Dimensions{ |
28 |
private: |
29 |
const dim_type *d; |
30 |
public: |
31 |
static const unsigned MAX_DIMS = NUM_DIMENS; |
32 |
static const std::string BASEUNITS[MAX_DIMS]; |
33 |
|
34 |
/// Return the string name of fundamental unit for the i-th dimension of measurement. |
35 |
static const std::string getBaseUnit(const unsigned &i); |
36 |
|
37 |
/// Construct a Dimension object fro mthe ASCEND internal data type |
38 |
Dimensions(const dim_type *d); |
39 |
|
40 |
/// Copy constructor |
41 |
Dimensions(const Dimensions &); |
42 |
|
43 |
/// Default constructor, required to keep std::vector happy |
44 |
Dimensions(); |
45 |
|
46 |
/// Return the ASCEND internal datatype |
47 |
const dim_type *getInternalType() const; |
48 |
|
49 |
const std::string toString() const; |
50 |
|
51 |
// Comparison operators |
52 |
const bool operator<(const Dimensions &) const; |
53 |
const bool operator==(const Dimensions &) const; |
54 |
const bool operator!=(const Dimensions &) const; |
55 |
|
56 |
/// Get default units for the given dimension |
57 |
// const UnitsM getDefaultUnits() const; # DEFINED IN PYTHON |
58 |
|
59 |
/// Get the user's preferred units for the given dimension |
60 |
//const UnitsM getUserUnits() const; # DEFINED IN PYTHON |
61 |
|
62 |
/// Test for a dimensionless Dimension object |
63 |
const bool isDimensionless() const; |
64 |
|
65 |
/// Test for a wildcard ('don't care') Dimension object |
66 |
const bool isWild() const; |
67 |
|
68 |
/// Get the numerator part of the index in the i-th dimension (eg for Area, with i={length}, return 2) |
69 |
const short getFractionNumerator(const unsigned &i) const; |
70 |
|
71 |
/// Get the denominator part of the index in the i-th dimension |
72 |
const short getFractionDenominator(const unsigned &i) const; |
73 |
}; |
74 |
|
75 |
#endif |