SheafSystem  0.0.0.0
sec_at1.cc
Go to the documentation of this file.
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 
20 
21 #include "SheafSystem/sec_at1.h"
22 
23 #include "SheafSystem/assert_contract.h"
24 #include "SheafSystem/binary_section_space_schema_member.impl.h"
25 #include "SheafSystem/binary_section_space_schema_poset.h"
26 #include "SheafSystem/fiber_bundles_namespace.h"
27 #include "SheafSystem/sec_at0.h"
28 #include "SheafSystem/sec_at0_space.h"
29 #include "SheafSystem/sec_at1_space.h"
30 #include "SheafSystem/sec_tuple_space.impl.h"
31 #include "SheafSystem/section_space_schema_member.impl.h"
32 #include "SheafSystem/section_space_schema_poset.h"
33 #include "SheafSystem/at1.h"
34 #include "SheafSystem/at1_space.h"
35 
36 
37 using namespace std;
38 using namespace fiber_bundle; // Workaround for MS C++ bug.
39 
40 //==============================================================================
41 // CLASS SEC_AT1
42 //==============================================================================
43 
44 // ===========================================================
45 // HOST FACTORY FACET OF CLASS SEC_AT1
46 // ===========================================================
47 
48 // PUBLIC MEMBER FUNCTIONS
49 
53  const poset_path& xhost_path,
54  const poset_path& xschema_path,
55  const poset_path& xscalar_space_path,
56  bool xauto_access)
57 {
58  // cout << endl << "Entering sec_at1::new_host." << endl;
59 
60  // Preconditions:
61 
62  require(xns.state_is_auto_read_write_accessible(xauto_access));
63 
64  require(!xhost_path.empty());
65  require(!xns.contains_path(xhost_path, xauto_access));
66 
67  require(xschema_path.full());
68  require(xns.path_is_auto_read_accessible<schema_type::host_type>(xschema_path, xauto_access));
69  require(host_type::fiber_space_conforms<fiber_type::host_type>(xns, xschema_path, xauto_access));
70 
71  require(xns.path_is_auto_read_accessible<scalar_type::host_type>(xscalar_space_path, xauto_access));
72 
73  require(host_type::same_scalar_fiber_space(xns, xschema_path, xscalar_space_path, xauto_access));
74 
75  // Body:
76 
77  host_type& result = host_type::new_table(xns, xhost_path, xschema_path, xscalar_space_path, xauto_access);
78 
79  // Postconditions:
80 
81  ensure(xns.owns(result, xauto_access));
82  ensure(result.path(true) == xhost_path);
83  ensure(result.state_is_not_read_accessible());
84  ensure(result.schema(true).path(xauto_access) == xschema_path);
85 
86  ensure(result.factor_ct(true) == result.schema(true).fiber_space<fiber_type::host_type>().factor_ct(xauto_access));
87  ensure(result.d(true) == result.schema(true).fiber_space<fiber_type::host_type>().d(xauto_access));
88  ensure(result.d(true) == result.dd(true));
89  ensure(result.scalar_space_path(true) == xscalar_space_path);
90  ensure(result.p(true) == result.schema(true).fiber_space<fiber_type::host_type>().p(xauto_access));
91  ensure(result.p(true) == 1);
92  ensure(result.dd(true) == result.schema(true).fiber_space<fiber_type::host_type>().dd(xauto_access));
93  ensure(result.vector_space_path(true) == xhost_path);
94 
95  // Exit:
96 
97  // cout << "Leaving sec_at1::new_host." << endl;
98  return result;
99 }
100 
101 // PROTECTED MEMBER FUNCTIONS
102 
103 // PRIVATE MEMBER FUNCTIONS
104 
105 
106 //==============================================================================
107 // AT1 FACET OF CLASS SEC_AT1
108 //==============================================================================
109 
110 // PUBLIC MEMBER FUNCTIONS
111 
114 {
115 
116  // Preconditions:
117 
118  // Body:
119 
120  // Postconditions:
121 
122  ensure(invariant());
123 }
124 
126 sec_at1(const sec_rep_space* xhost, pod_index_type xhub_id)
127 {
128  // Preconditions:
129 
130  require(xhost != 0);
131  require(xhost->state_is_read_accessible());
132  require(xhost->contains_member(xhub_id));
133 
134  // Body:
135 
136  attach_to_state(xhost, xhub_id);
137 
138  // Postconditions:
139 
140  ensure(invariant());
141  ensure(host() == xhost);
142  ensure(index() == xhub_id);
143  ensure(is_attached());
144  ensure(!is_restricted());
145 }
146 
148 sec_at1(const sec_rep_space* xhost, const scoped_index& xid)
149 {
150 
151  // Preconditions:
152 
153  require(xhost != 0);
154  require(xhost->state_is_read_accessible());
155  require(xhost->contains_member(xid));
156 
157  // Body:
158 
159  attach_to_state(xhost, xid.hub_pod());
160 
161  // Postconditions:
162 
163  ensure(invariant());
164  ensure(host() == xhost);
165  ensure(index() ==~ xid);
166  ensure(is_attached());
167  ensure(!is_restricted());
168 }
169 
171 sec_at1(const sec_rep_space* xhost, const std::string& xname)
172 {
173 
174  // Preconditions:
175 
176  require(xhost != 0);
177  require(xhost->state_is_read_accessible());
178  require(!xname.empty());
179  require(xhost->contains_member(xname));
180 
181  // Body:
182 
183  attach_to_state(xhost, xname);
184 
185  // Postconditions:
186 
187  ensure(invariant());
188  ensure(host() == xhost);
189  ensure(name() == xname);
190  ensure(is_attached());
191  ensure(!is_restricted());
192 
193 }
194 
196 sec_at1(const namespace_poset* xnamespace,
197  const poset_path& xpath,
198  bool xauto_access)
199 {
200 
201  // Preconditions:
202 
203  require(precondition_of(attach_to_state(same args)));
204 
205  // Body:
206 
207  attach_to_state(xnamespace, xpath, xauto_access);
208 
209  // Postconditions:
210 
211  ensure(postcondition_of(attach_to_state(same args)));
212 
213  // Exit:
214 
215  return;
216 }
217 
220 {
221 
222  // Preconditions:
223 
224  require(xother != 0);
225 
226  // Body:
227 
228  attach_to_state(xother);
229 
230  // Postconditions:
231 
232  ensure(invariant());
233  ensure(is_attached());
234  ensure(is_same_state(xother));
235  ensure(is_same_restriction(xother));
236 
237 }
238 
240 sec_at1(sec_rep_space* xhost, section_dof_map* xdof_map, bool xauto_access)
241 {
242  // Preconditions:
243 
244  require(precondition_of(new_jim_state(xhost, xdof_map, false, xauto_access)));
245 
246  // Body:
247 
248  new_jim_state(xhost, xdof_map, false, xauto_access);
249 
250  // Postconditions:
251 
252  ensure(postcondition_of(new_jim_state(xhost, xdof_map, false, xauto_access)));
253 
254  // Exit:
255 
256  return;
257 }
258 
261  abstract_poset_member& xbase_mbr,
262  int xbase_version, bool xauto_access)
263 {
264 
265  // Preconditions:
266 
267  require(precondition_of(new_jim_state(xhost, xbase_mbr, xbase_version, xauto_access)));
268 
269  // Body:
270 
271  new_jim_state(xhost, xbase_mbr, xbase_version, xauto_access);
272 
273  // Postconditions:
274 
275  ensure(postcondition_of(new_jim_state(xhost, xbase_mbr, xbase_version, xauto_access)));
276 
277  // Exit:
278 
279  return;
280 }
281 
285 {
286  // Preconditions:
287 
288  require(is_ancestor_of(&xother));
289  require(precondition_of(attach_to_state(&xother)));
290 
291  // Body:
292 
293  attach_to_state(&xother);
294 
295  // Postconditions:
296 
297  ensure(postcondition_of(attach_to_state(&xother)));
298 
299  // Exit:
300 
301  return *this;
302 }
303 
306 operator=(const sec_at1& xother)
307 {
308  // Preconditions:
309 
310  require(precondition_of(attach_to_state(&xother)));
311 
312  // Body:
313 
314  attach_to_state(&xother);
315 
316  // Postconditions:
317 
318  ensure(postcondition_of(attach_to_state(&xother)));
319 
320  // Exit:
321 
322  return *this;
323 }
324 
327 operator=(const at1& xfiber)
328 {
329  // Preconditions:
330 
331  require(precondition_of(sec_vd::operator=(xfiber)));
332 
333  // Body:
334 
335  sec_vd::operator=(xfiber);
336 
337  // Postconditions:
338 
339  ensure(postcondition_of(sec_vd::operator=(xfiber)));
340 
341  // Exit:
342 
343  return *this;
344 }
345 
348 operator=(const at1_lite& xfiber)
349 {
350  // Preconditions:
351 
352  require(precondition_of(sec_vd::operator=(xfiber)));
353 
354  // Body:
355 
356  sec_vd::operator=(xfiber);
357 
358  // Postconditions:
359 
360  ensure(postcondition_of(sec_vd::operator=(xfiber)));
361 
362  // Exit:
363 
364  return *this;
365 }
366 
369 {
370  // Preconditions:
371 
372  // Body:
373 
374  // Postconditions:
375 
376 }
377 
381 {
382  // Preconditions:
383 
384  // Body:
385 
386  static const fiber_type result;
387 
388  // Postconditions:
389 
390  // Exit:
391 
392  return result;
393 }
394 
395 // PROTECTED MEMBER FUNCTIONS
396 
397 // PRIVATE MEMBER FUNCTIONS
398 
399 
400 //==============================================================================
401 // ATP FACET OF CLASS SEC_AT1
402 //==============================================================================
403 
404 // PUBLIC MEMBER FUNCTIONS
405 
406 // PROTECTED MEMBER FUNCTIONS
407 
408 // PRIVATE MEMBER FUNCTIONS
409 
410 
411 //==============================================================================
412 // TP FACET OF CLASS SEC_AT1
413 //==============================================================================
414 
415 // PUBLIC MEMBER FUNCTIONS
416 
417 // PROTECTED MEMBER FUNCTIONS
418 
419 // PRIVATE MEMBER FUNCTIONS
420 
421 
422 //==============================================================================
423 // VD FACET OF CLASS SEC_AT1
424 //==============================================================================
425 
426 // PUBLIC MEMBER FUNCTIONS
427 
428 // PROTECTED MEMBER FUNCTIONS
429 
430 // PRIVATE MEMBER FUNCTIONS
431 
432 
433 //==============================================================================
434 // TUPLE FACET OF CLASS SEC_AT1
435 //==============================================================================
436 
437 // PUBLIC MEMBER FUNCTIONS
438 
439 // PROTECTED MEMBER FUNCTIONS
440 
441 // PRIVATE MEMBER FUNCTIONS
442 
443 
444 //==============================================================================
445 // ABSTRACT POSET MEMBER FACET OF CLASS SEC_AT1
446 //==============================================================================
447 
448 // PUBLIC MEMBER FUNCTIONS
449 
450 const std::string&
452 class_name() const
453 {
454  // Preconditions:
455 
456  // Body:
457 
458  const string& result = static_class_name();
459 
460  // Postconditions:
461 
462  ensure(!result.empty());
463 
464  // Exit:
465 
466  return result;
467 }
468 
469 const std::string&
472 {
473  // Preconditions:
474 
475  // Body:
476 
477  static const string result("sec_at1");
478 
479  // Postconditions:
480 
481  ensure(!result.empty());
482 
483  // Exit:
484 
485  return result;
486 }
487 
490 clone() const
491 {
492 
493  // Preconditions:
494 
495  // Body:
496 
497  // create new handle of the current class.
498 
499  sec_at1 *result = new sec_at1();
500 
501  // Postconditions:
502 
503  ensure(result != 0);
504  ensure(result->invariant());
505 
506  // Exit:
507 
508  return result;
509 
510 }
511 
512 // PROTECTED MEMBER FUNCTIONS
513 
514 // PRIVATE MEMBER FUNCTIONS
515 
516 
517 // ===========================================================
518 // POSET_COMPONENT FACET
519 // ===========================================================
520 
521 // PUBLIC MEMBER FUNCTIONS
522 
525 host() const
526 {
527  return reinterpret_cast<host_type*>(_host);
528 }
529 
530 bool
533 {
534  return dynamic_cast<const host_type*>(xother) != 0;
535 }
536 
537 // PROTECTED MEMBER FUNCTIONS
538 
539 // PRIVATE MEMBER FUNCTIONS
540 
541 
542 //==============================================================================
543 // ANY FACET OF CLASS SEC_AT1
544 //==============================================================================
545 
546 // PUBLIC MEMBER FUNCTIONS
547 
548 bool
550 fiber_is_ancestor_of(const any* xother) const
551 {
552 
553  // Preconditions:
554 
555  require(xother != 0);
556 
557  // Body:
558 
559  // If xother may be dynamically cast to the type of this fiber then this
560  // fiber is an ancestor of xother.
561 
562  bool result = dynamic_cast<const at1*>(xother) != 0;
563 
564  // Postconditions:
565 
566  ensure(invariant());
567  ensure(xother->invariant());
568 
569  // Exit:
570 
571  return result;
572 
573 }
574 
575 bool
577 is_ancestor_of(const any* xother) const
578 {
579 
580  // Preconditions:
581 
582  require(xother != 0);
583 
584  // Body:
585 
586  // If other may be dynamically cast to the type of this then this is an
587  // ancestor of other.
588 
589  bool result = dynamic_cast<const sec_at1*>(xother) != 0;
590 
591  // Postconditions:
592 
593  //ensure(invariant());
594 
595  // Exit:
596 
597  return result;
598 
599 }
600 
601 bool
603 invariant() const
604 {
605  bool result = true;
606 
607  // Preconditions:
608 
609  // Body:
610 
611  // Must satisfy base class invariant
612 
613  invariance(sec_atp::invariant());
614 
615  if(invariant_check())
616  {
617  // Prevent recursive calls to invariant
618 
619  disable_invariant_check();
620 
621  invariance(is_attached() ? p() == 1 : true);
622 
623  // Finished, turn invariant checking back on.
624 
625  enable_invariant_check();
626  }
627 
628  // Postconditions:
629 
630  ensure(is_derived_query);
631 
632  // Exit:
633 
634  return result;
635 }
636 
637 // PROTECTED MEMBER FUNCTIONS
638 
639 // PRIVATE MEMBER FUNCTIONS
640 
virtual bool invariant() const
Class invariant, intended to be redefined in each descendant. See below for template for invariant in...
Definition: any.cc:153
static int factor_ct(int xd)
Factor_ct() as a function of dimension xd.
virtual poset_path path(bool xauto_access=true) const
The path of this poset.
bool state_is_auto_read_write_accessible(bool xauto_access) const
True if state is auto accessible for read and write, that is, if the state is already accessible for ...
static host_type & new_host(namespace_type &xns, const poset_path &xhost_path, const poset_path &xschema_path, const poset_path &xscalar_space_path, bool xauto_access)
Creates a new host table for members of this type. The poset is created in namespace xns with path xh...
Definition: sec_at1.cc:52
bool full() const
True if both poset name and member name are not empty.
Definition: poset_path.cc:311
sec_at1()
Default constructor.
Definition: sec_at1.cc:113
A Cartesian product section space.
The abstract map from section dof ids to section dof values of heterogeneous type.
A space of scalars viewed as an antisymmetric tensor section space of degree 1.
Definition: sec_at1_space.h:48
poset_path path(bool xauto_access=true) const
A path to this component.
The default name space; a poset which contains other posets as members.
bool state_is_read_accessible() const
True if this is attached and if the state is accessible for read or access control is disabled...
bool path_is_auto_read_accessible(const poset_path &xpath, bool xauto_access) const
True if the state referred to xpath exists and is auto read accessible.
A general antisymmetric tensor of degree 1 over an abstract vector space (persistent version)...
Definition: at1.h:211
The standard fiber bundles name space; extends the standard sheaves namespace by defining base space...
virtual sec_at1 & operator=(const abstract_poset_member &xother)
Assignment operator; synonym for attach_to_state(&xother).
Definition: sec_at1.cc:284
A general antisymmetric tensor of degree 1 over an abstract vector space (volatile version)...
Definition: at1.h:44
bool invariant() const
Class invariant.
Definition: sec_at1.cc:603
A client handle for a general, abstract partially order set.
A path defined by a poset name and a member name separated by a forward slash (&#39;/&#39;). For example: "cell_definitions/triangle".
Definition: poset_path.h:48
A member of a sec_rep_space; a section.
poset_path vector_space_path() const
The path of the underlying vector space.
STL namespace.
virtual sec_at1 * clone() const
Make a new handle, no state instance of current.
Definition: sec_at1.cc:490
bool fiber_is_ancestor_of(const any *xother) const
True if xother conforms to an instance of the fiber of current.
Definition: sec_at1.cc:550
A schema poset for a section space. A binary Cartesian product subspace of the binary tensor product ...
host_type * host() const
The poset this is a member of.
Definition: sec_at1.cc:525
virtual const fiber_type & fiber_prototype() const
Virtual constructor for the associated fiber type.
Definition: sec_at1.cc:380
A section of a bundle with fiber type at1.
Definition: sec_at1.h:48
~sec_at1()
Destructor.
Definition: sec_at1.cc:368
Abstract base class with useful features for all objects.
Definition: any.h:39
int p() const
The tensor degree of this space.
virtual section_space_schema_member & schema()
The schema for this poset (mutable version)
static const std::string & static_class_name()
The name of this class.
Definition: sec_at1.cc:471
virtual bool host_is_ancestor_of(const poset_state_handle *other) const
True if other conforms to host.
Definition: sec_at1.cc:532
bool owns(const poset_state_handle &xposet, bool xauto_access) const
True if and only if this contains the poset xposet. synonym for contains_poset(xposet.poset_path(true), xauto_access)
An index within the external ("client") scope of a given id space.
Definition: scoped_index.h:116
bool contains_path(const poset_path &xpath, bool xauto_access=true) const
True if this contains the poset or poset member specified by xpath.
virtual bool contains_member(pod_index_type xmbr_hub_id, bool xauto_access=true) const
True if some version of this poset contains poset member with hub id xmbr_hub_id. ...
int dd() const
The dimension of the underlying ("domain") vector space.
bool empty() const
True if both poset name and member name are empty.
Definition: poset_path.cc:291
virtual const std::string & class_name() const
The name of this class.
Definition: sec_at1.cc:452
An abstract vector space viewed as an antisymmetric tensor space of degree 1.
Definition: at1_space.h:42
int_type pod_index_type
The plain old data index type.
Definition: pod_types.h:49
poset_path scalar_space_path() const
The path of the underlying space of scalars.
poset & fiber_space()
The fiber space for section spaces on this schema (mutable version).
An abstract client handle for a member of a poset.
Namespace for the fiber_bundles component of the sheaf system.
virtual int d(int xp, int xdd) const
Dimension d() as a function of degree xp and domain dimension xdd.
bool state_is_not_read_accessible() const
True if this is attached and if the state is accessible for read or if access control is disabled...
bool is_ancestor_of(const any *xother) const
True if xother conforms to current.
Definition: sec_at1.cc:577
pod_type hub_pod() const
The pod value of this mapped to the unglued hub id space.
Definition: scoped_index.h:710
A handle for a poset whose members are numerical representations of sections of a fiber bundle...
Definition: sec_rep_space.h:61