SheafSystem  0.0.0.0
standard_dof_tuple_index.cc
1 
2 //
3 // Copyright (c) 2014 Limit Point Systems, Inc.
4 //
5 // Licensed under the Apache License, Version 2.0 (the "License");
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17 
18 // Definitions for standard_dof_tuple_index facet of namespace sheaf.
19 
20 
21 #include "SheafSystem/standard_dof_tuple_index.h"
22 
23 #include "SheafSystem/assert_contract.h"
24 #include "SheafSystem/std_string.h"
25 
26 using namespace std;
27 
28 namespace
29 {
30 const int STANDARD_DOF_TUPLE_INDEX_CT =
31  sheaf::STANDARD_DOF_TUPLE_INDEX_END - sheaf::STANDARD_DOF_TUPLE_INDEX_BEGIN;
32 }
33 
36 sheaf::
38 {
39  return x =
40  (x == STANDARD_DOF_TUPLE_INDEX_END) ?
41  STANDARD_DOF_TUPLE_INDEX_BEGIN :
43 };
44 
46 const std::string&
47 sheaf::
49 {
50  // Preconditions:
51 
52  // Body:
53 
54  static const string names[STANDARD_DOF_TUPLE_INDEX_CT+1] =
55  {
56  "EMPTY_DOF_TUPLE_INDEX",
57  "NOT_A_STANDARD_DOF_TUPLE_INDEX"
58  };
59 
60  const string* lresult_ptr = &names[STANDARD_DOF_TUPLE_INDEX_CT];
61 
62  pod_index_type lpt = xpt;
64  {
65  lresult_ptr = &names[lpt - STANDARD_DOF_TUPLE_INDEX_BEGIN];
66  }
67 
68  const string& result = *lresult_ptr;
69 
70  // Postconditions:
71 
72  ensure(!result.empty());
73 
74  // Exit:
75 
76  return result;
77 }
78 
81 sheaf::
82 standard_dof_tuple_index_from_name(const std::string& xname)
83 {
84  standard_dof_tuple_index result = NOT_A_STANDARD_DOF_TUPLE_INDEX;
85  for(standard_dof_tuple_index i=STANDARD_DOF_TUPLE_INDEX_BEGIN;
86  i< STANDARD_DOF_TUPLE_INDEX_END;
87  ++i)
88  {
89  if(standard_dof_tuple_index_to_name(i) == xname)
90  {
91  result = i;
92  break;
93  }
94  }
95 
96  return result;
97 }
98 
101 sheaf::
103 {
104  // Preconditions:
105 
106  // Body:
107 
108  static const standard_dof_tuple_index prims[STANDARD_DOF_TUPLE_INDEX_CT+1] =
109  {
110  EMPTY_DOF_TUPLE_INDEX,
111  NOT_A_STANDARD_DOF_TUPLE_INDEX
112  };
113 
114  standard_dof_tuple_index result = prims[STANDARD_DOF_TUPLE_INDEX_CT];
115  if(is_standard_dof_tuple_index(xindex))
116  {
117  result = prims[xindex];
118  }
119 
120  // Postconditions:
121 
122  // Exit:
123 
124  return result;
125 }
126 
128 bool
129 sheaf::
131 {
132  bool result;
133 
134  // Preconditions:
135 
136  // Body:
137 
138  result =
139  (STANDARD_DOF_TUPLE_INDEX_BEGIN <= xindex) && (xindex < STANDARD_DOF_TUPLE_INDEX_END);
140 
141  // Postconditions:
142 
143  // Exit
144 
145  return result;
146 }
147 
SHEAF_DLL_SPEC standard_dof_tuple_index standard_dof_tuple_index_from_index(pod_index_type xindex)
The enumerator corresponding to primitive index xindex.
STL namespace.
standard_dof_tuple_index
Ids for standard dof tuples.
SHEAF_DLL_SPEC standard_dof_tuple_index standard_dof_tuple_index_from_name(const std::string &xname)
The enumerator with name xname.
SHEAF_DLL_SPEC bool is_standard_dof_tuple_index(pod_index_type xindex)
True if xindex is a valid primitive index.
int_type pod_index_type
The plain old data index type.
Definition: pod_types.h:49
SHEAF_DLL_SPEC const std::string & standard_dof_tuple_index_to_name(standard_dof_tuple_index xpt)
The name of the enumerator xpt.
SHEAF_DLL_SPEC namespace_member_index & operator++(namespace_member_index &x)
Prefix increment operator for namespace_member_index.