SheafSystem  0.0.0.0
jcb_ed.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/jcb_ed.h"
22 
23 #include "SheafSystem/abstract_poset_member.impl.h"
24 #include "SheafSystem/assert_contract.h"
25 #include "SheafSystem/at1.h"
26 #include "SheafSystem/at1_space.h"
27 #include "SheafSystem/ed.h"
28 #include "SheafSystem/jcb_space.h"
29 #include "SheafSystem/fiber_bundles_namespace.h"
30 #include "SheafSystem/schema_poset_member.h"
31 #include "SheafSystem/wsv_block.h"
32 
33 
34 using namespace std;
35 using namespace fiber_bundle; // Workaround for MS C++ bug.
36 
37 
38 //==============================================================================
39 // CLASS JDB_ED_LITE
40 //==============================================================================
41 
42 //==============================================================================
43 // JCB_ED FACET OF CLASS JCB_ED_LITE
44 //==============================================================================
45 
46 // PUBLIC MEMBER FUNCTIONS
47 
50 {
51 
52  // Preconditions:
53 
54  // Body:
55 
56  // Postconditions:
57 
58  ensure(invariant());
59 
60  // Exit:
61 }
62 
64 jcb_ed_lite(const jcb_ed_lite& xother)
65 {
66  // Preconditions:
67 
68  // Body:
69 
70  // Postconditions:
71 
72  ensure(invariant());
73 
74  // Exit:
75 }
76 
79 operator=(const jcb_ed_lite& xother)
80 {
81 
82  // Preconditions:
83 
84 
85  // Body:
86 
87 
88  // Postconditions:
89 
90  ensure(invariant());
91 
92  // Exit:
93 
94  return *this;
95 }
96 
99 {
100 
101  // Preconditions:
102 
103 
104  // Body:
105 
106 
107  // Postconditions:
108 
109  // Exit:
110 
111 }
112 
114 jcb_ed_lite(const row_dofs_type& xrow_dofs)
115 {
116  // Preconditions:
117 
118  // Body:
119 
120  *this = xrow_dofs;
121 
122  // Postconditions:
123 
124  ensure(invariant());
125 
126  // Exit:
127 }
128 
131 operator=(const row_dofs_type& xrow_dofs)
132 {
133  // Preconditions:
134 
135  // Body:
136 
137  vd_lite::operator=(xrow_dofs);
138 
139  // Postconditions:
140 
141  postcondition_of(vd_lite::operator=(xrow_dofs));
142 
143  // Exit:
144 
145  return *this;
146 
147 }
148 
149 // PROTECTED MEMBER FUNCTIONS
150 
151 // PRIVATE MEMBER FUNCTIONS
152 
153 
154 //==============================================================================
155 // VECTOR ALGEBRA (VD) FACET OF CLASS JCB_ED_LITE
156 //==============================================================================
157 
158 // PUBLIC MEMBER FUNCTIONS
159 
160 // PROTECTED MEMBER FUNCTIONS
161 
162 // PRIVATE MEMBER FUNCTIONS
163 
164 
165 //==============================================================================
166 // CARTESIAN ALGEBRA (TUPLE) FACET OF CLASS JCB_ED_LITE
167 //==============================================================================
168 
169 // PUBLIC MEMBER FUNCTIONS
170 
171 // PROTECTED MEMBER FUNCTIONS
172 
173 // PRIVATE MEMBER FUNCTIONS
174 
175 
176 //==============================================================================
177 // ABSTRACT POSET MEMBER FACET OF CLASS JCB_ED_LITE
178 //==============================================================================
179 
180 // PUBLIC MEMBER FUNCTIONS
181 
182 const std::string&
184 class_name() const
185 {
186  // Preconditions:
187 
188  // Body:
189 
190  const string& result = static_class_name();
191 
192  // Postconditions:
193 
194  ensure(!result.empty());
195 
196  // Exit:
197 
198  return result;
199 }
200 
201 const std::string&
204 {
205  // Preconditions:
206 
207  // Body:
208 
209  static const string result("jcb_ed_lite");
210 
211  // Postconditions:
212 
213  ensure(!result.empty());
214 
215  // Exit:
216 
217  return result;
218 }
219 
222 clone() const
223 {
224  jcb_ed_lite* result = 0;
225 
226  // Preconditions:
227 
228  // Body:
229 
230  result = new jcb_ed_lite();
231 
232  // Postconditions:
233 
234  ensure(result != 0);
235  ensure(is_same_type(*result));
236 
237  // Exit:
238 
239  return result;
240 }
241 
242 // PROTECTED MEMBER FUNCTIONS
243 
244 // PRIVATE MEMBER FUNCTIONS
245 
246 
247 //==============================================================================
248 // ANY FACET OF CLASS JCB_ED_LITE
249 //==============================================================================
250 
251 // PUBLIC MEMBER FUNCTIONS
252 
253 bool
255 is_ancestor_of(const any_lite& xother) const
256 {
257  // Preconditions:
258 
259  require(&xother != 0);
260 
261  // Body:
262 
263  // True if other conforms to this.
264 
265  bool result = dynamic_cast<const jcb_ed_lite*>(&xother) != 0;
266 
267  // Postconditions:
268 
269  return result;
270 }
271 
272 bool
274 invariant() const
275 {
276  bool result = true;
277 
278  if(invariant_check())
279  {
280  // Prevent recursive calls to invariant.
281 
282  disable_invariant_check();
283 
284  // Must satisfy base class invariant.
285 
286  invariance(jcb_lite::invariant());
287 
288  // Invariances for this class:
289 
290  // Finished, turn invariant checking back on.
291 
292  enable_invariant_check();
293  }
294 
295  // Exit
296 
297  return result;
298 }
299 
300 // PROTECTED MEMBER FUNCTIONS
301 
302 // PRIVATE MEMBER FUNCTIONS
303 
304 
305 //==============================================================================
306 // CLASS JDB_ED
307 //==============================================================================
308 
309 // ===========================================================
310 // HOST FACTORY FACET
311 // ===========================================================
312 
313 // PUBLIC MEMBER FUNCTIONS
314 
315 const sheaf::poset_path&
318 {
319  // Preconditions:
320 
321 
322  // Body:
323 
324  static const poset_path result(standard_schema_poset_name(), "jcb_ed_schema");
325 
326  // Postconditions:
327 
328  ensure(result.full());
329  ensure(result.poset_name() == standard_schema_poset_name());
330 
331  // Exit:
332 
333  return result;
334 }
335 
336 void
339 {
340  // Preconditions:
341 
342  require(xns.state_is_read_write_accessible());
343  require(xns.contains_poset(standard_schema_poset_name()));
344  require(!xns.contains_poset_member(standard_schema_path()));
345 
346  // Body:
347 
348  schema_poset_member lschema(xns,
349  standard_schema_path().member_name(),
350  jcb::standard_schema_path(),
351  "",
352  false);
353 
354  lschema.detach_from_state();
355 
356  // Postconditions:
357 
358  ensure(xns.contains_poset_member(standard_schema_path()));
359 
360  // Exit:
361 
362  return;
363 }
364 
368  const poset_path& xhost_path,
369  const poset_path& xschema_path,
370  const poset_path& xdomain_path,
371  const poset_path& xrange_path,
372  bool xauto_access)
373 {
374  // cout << endl << "Entering jcb_ed::new_host." << endl;
375 
376  // Preconditions:
377 
378  require(xns.state_is_auto_read_write_accessible(xauto_access));
379 
380  require(!xhost_path.empty());
381  require(!xns.contains_path(xhost_path, xauto_access));
382 
383  require(xschema_path.full());
384  require(xns.path_is_auto_read_accessible(xschema_path, xauto_access));
385  require(schema_poset_member::conforms_to(xns, xschema_path, standard_schema_path()));
386 
387  require(xns.path_is_auto_read_accessible<domain_type::host_type>(xdomain_path, xauto_access));
388  require(xns.path_is_auto_read_accessible<range_type::host_type>(xrange_path, xauto_access));
389 
390  require(host_type::d(xns, xschema_path, xauto_access) == host_type::d(xns, xdomain_path, xrange_path, xauto_access));
391 
392  require(xns.member_poset<domain_type::host_type>(xdomain_path, xauto_access).scalar_space_path(xauto_access) ==
393  xns.member_poset<range_type::host_type>(xrange_path, xauto_access).scalar_space_path(xauto_access));
394 
395  // Body:
396 
397  host_type& result =
398  host_type::new_table(xns, xhost_path, xschema_path, xdomain_path, xrange_path, xauto_access);
399 
400  // Postconditions:
401 
402  ensure(xns.owns(result, xauto_access));
403  ensure(result.path(true) == xhost_path);
404  ensure(result.state_is_not_read_accessible());
405  ensure(result.schema(true).path(xauto_access) == xschema_path);
406 
407  ensure(result.factor_ct(true) == result.d(true));
408  ensure(result.d(true) == host_type::d(xns, xschema_path, xauto_access));
409 
410  ensure(result.domain_path(true) == xdomain_path);
411  ensure(result.dd(true) == xns.member_poset<domain_type::host_type>(xdomain_path, xauto_access).d());
412 
413  ensure(result.range_path(true) == xrange_path);
414  ensure(result.dr(true) == xns.member_poset<range_type::host_type>(xrange_path, xauto_access).d());
415 
416  ensure(result.scalar_space_path(true) ==
417  xns.member_poset<domain_type::host_type>(xdomain_path, xauto_access).scalar_space_path(xauto_access) );
418  ensure(result.scalar_space_path(true) ==
419  xns.member_poset<range_type::host_type>(xrange_path, xauto_access).scalar_space_path(xauto_access) );
420 
421  // Exit:
422 
423  // cout << "Leaving jcb_ed::new_host." << endl;
424  return result;
425 }
426 
427 
428 // PROTECTED MEMBER FUNCTIONS
429 
430 // PRIVATE MEMBER FUNCTIONS
431 
432 
433 //==============================================================================
434 // JCB_ED FACET OF CLASS JCB_ED
435 //==============================================================================
436 
437 // PUBLIC MEMBER FUNCTIONS
438 
441 {
442 
443  // Preconditions:
444 
445  // Body:
446 
447  // Postconditions:
448 
449  ensure(invariant());
450 }
451 
454 {
455  // Preconditions:
456 
457  require(xhost != 0);
458  require(xhost->state_is_read_accessible());
459  require(xhost->contains_member(xhub_id));
460 
461  // Body:
462 
463  attach_to_state(xhost, xhub_id);
464 
465  // Postconditions:
466 
467  ensure(invariant());
468  // ensure(host() == xhost);
469  ensure(index() == xhub_id);
470  ensure(is_attached());
471 }
472 
474 jcb_ed(const poset_state_handle* xhost, const scoped_index& xid)
475 {
476  // Preconditions:
477 
478  require(xhost != 0);
479  require(xhost->state_is_read_accessible());
480  require(xhost->contains_member(xid));
481 
482  // Body:
483 
484  attach_to_state(xhost, xid.hub_pod());
485 
486  // Postconditions:
487 
488  ensure(invariant());
489  // ensure(host() == xhost);
490  ensure(index() ==~ xid);
491  ensure(is_attached());
492 }
493 
495 jcb_ed(const poset_state_handle* xhost, const std::string& xname)
496 {
497 
498  // Preconditions:
499 
500  require(xhost != 0);
501  require(xhost->state_is_read_accessible());
502  require(!xname.empty());
503  require(xhost->contains_member(xname));
504 
505  // Body:
506 
507  attach_to_state(xhost, xname);
508 
509  // Postconditions:
510 
511  ensure(invariant());
512  // ensure(host() == xhost);
513  ensure(name() == xname);
514  ensure(is_attached());
515 
516 }
517 
520 {
521 
522  // Preconditions:
523 
524  require(xother != 0);
525 
526  // Body:
527 
528  attach_to_state(xother);
529 
530  // Postconditions:
531 
532  ensure(invariant());
533  ensure(is_attached());
534  ensure(is_same_state(xother));
535 
536 }
537 
539 jcb_ed(poset_state_handle* xhost, bool xauto_access)
540 {
541 
542  // Preconditions:
543 
544  require(precondition_of(new_jim_state(xhost, 0, false, xauto_access)));
545 
546  // Body:
547 
548  new_jim_state(xhost, 0, false, xauto_access);
549 
550  // Postconditions:
551 
552  ensure(postcondition_of(new_jim_state(xhost, 0, false, xauto_access)));
553 
554  // Exit:
555 
556  return;
557 }
558 
563 {
564  // Preconditions:
565 
566  require(is_ancestor_of(&xother));
567  require(precondition_of(attach_to_state(&xother)));
568 
569  // Body:
570 
571  attach_to_state(&xother);
572 
573  // Postconditions:
574 
575  ensure(postcondition_of(attach_to_state(&xother)));
576 
577  // Exit:
578 
579  return *this;
580 }
581 
585 operator=(const jcb_ed& xother)
586 {
587  // Preconditions:
588 
589  require(precondition_of(attach_to_state(&xother)));
590 
591  // Body:
592 
593  attach_to_state(&xother);
594 
595  // Postconditions:
596 
597  ensure(postcondition_of(attach_to_state(&xother)));
598 
599  // Exit:
600 
601  return *this;
602 }
603 
606 {
607 
608  // Preconditions:
609 
610  // Body:
611 
612  // Postconditions:
613 
614 }
615 
619 {
620  // Preconditions:
621 
622  // Body:
623 
624  static const volatile_type result;
625 
626  // Postconditions:
627 
628  // Exit:
629 
630  return result;
631 }
632 
636 lite_type() const
637 {
638  // Preconditions:
639 
640  // Body:
641 
642  volatile_type* result = new volatile_type(sheaf::row_dofs(*this));
643 
644  // Postconditions:
645 
646  // Exit:
647 
648  return result;
649 }
650 
651 
652 // PROTECTED MEMBER FUNCTIONS
653 
654 // PRIVATE MEMBER FUNCTIONS
655 
656 
657 //==============================================================================
658 // VD FACET OF CLASS JCB_ED
659 //==============================================================================
660 
661 // PUBLIC MEMBER FUNCTIONS
662 
663 // PROTECTED MEMBER FUNCTIONS
664 
665 // PRIVATE MEMBER FUNCTIONS
666 
667 
668 //==============================================================================
669 // TUPLE FACET OF CLASS JCB_ED
670 //==============================================================================
671 
672 // PUBLIC MEMBER FUNCTIONS
673 
674 // PROTECTED MEMBER FUNCTIONS
675 
676 // PRIVATE MEMBER FUNCTIONS
677 
678 
679 //==============================================================================
680 // ABSTRACT POSET MEMBER FACET OF CLASS JCB_ED
681 //==============================================================================
682 
683 // PUBLIC MEMBER FUNCTIONS
684 
685 const std::string&
687 class_name() const
688 {
689  // Preconditions:
690 
691  // Body:
692 
693  const string& result = static_class_name();
694 
695  // Postconditions:
696 
697  ensure(!result.empty());
698 
699  // Exit:
700 
701  return result;
702 }
703 
704 const std::string&
707 {
708  // Preconditions:
709 
710  // Body:
711 
712  static const string result("jcb_ed");
713 
714  // Postconditions:
715 
716  ensure(!result.empty());
717 
718  // Exit:
719 
720  return result;
721 }
722 
725 clone() const
726 {
727 
728  // Preconditions:
729 
730  // Body:
731 
732  // Create new handle of the current class.
733 
734  jcb_ed* result = new jcb_ed();
735 
736  // Postconditions:
737 
738  ensure(result != 0);
739  ensure(result->invariant());
740 
741  // Exit:
742 
743  return result;
744 
745 }
746 
747 // PROTECTED MEMBER FUNCTIONS
748 
749 // PRIVATE MEMBER FUNCTIONS
750 
751 
752 //==============================================================================
753 // ANY FACET OF CLASS JCB_ED
754 //==============================================================================
755 
756 // PUBLIC MEMBER FUNCTIONS
757 
758 bool
760 is_ancestor_of(const any* xother) const
761 {
762 
763  // Preconditions:
764 
765  require(xother != 0);
766 
767  // Body:
768 
769  // If xother may be dynamically cast to the type of this then this is an
770  // ancestor of other.
771 
772  bool result = dynamic_cast<const jcb_ed*>(xother) != 0;
773 
774  // Postconditions:
775 
776  // ensure(invariant());
777 
778  return result;
779 
780 }
781 
782 bool
784 invariant() const
785 {
786  bool result = true;
787 
788  // Preconditions:
789 
790  // Body:
791 
792  // Must satisfy base class invariant.
793 
794  invariance(jcb::invariant());
795 
796  if (invariant_check())
797  {
798  // Prevent recursive calls to invariant.
799 
800  disable_invariant_check();
801 
802  // Finished, turn invariant checking back on.
803 
804  enable_invariant_check();
805  }
806 
807  // Postconditions:
808 
809  ensure(is_derived_query);
810 
811  // Exit:
812 
813  return result;
814 }
815 
816 // PROTECTED MEMBER FUNCTIONS
817 
818 // PRIVATE MEMBER FUNCTIONS
819 
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 ...
bool full() const
True if both poset name and member name are not empty.
Definition: poset_path.cc:311
Abstract jacobian for d dimensional Euclidean space (volatile version).
Definition: jcb_ed.h:44
The default name space; a poset which contains other posets as members.
bool invariant() const
Class invariant.
Definition: jcb_ed.cc:274
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.
The standard fiber bundles name space; extends the standard sheaves namespace by defining base space...
virtual const std::string & class_name() const
The name of this class.
Definition: jcb_ed.cc:687
bool contains_poset_member(pod_index_type xposet_hub_id, pod_index_type xmember_hub_id, bool xauto_access=true) const
True if this contains a poset with hub id xposet_hub_id which contains a member with hub id xmember_h...
A client handle for a general, abstract partially order set.
static const std::string & static_class_name()
The name of this class.
Definition: jcb_ed.cc:203
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
STL namespace.
virtual jcb_ed * clone() const
Make a new handle, no state instance of current.
Definition: jcb_ed.cc:725
virtual ~jcb_ed_lite()
Destructor.
Definition: jcb_ed.cc:98
poset_state_handle & member_poset(pod_index_type xhub_id, bool xauto_access=true) const
The poset_state_handle object referred to by hub id xhub_id.
T::row_dofs_type & row_dofs(T &x0)
The row dofs pod type for x0 (mutable version).
static const std::string & static_class_name()
The name of this class.
Definition: jcb_ed.cc:706
static void make_standard_schema(namespace_poset &xns)
Creates the standard schema for this class in namespace xns.
Definition: jcb_ed.cc:338
Abstract base class with useful features for all volatile objects.
Definition: any_lite.h:48
Abstract base class with useful features for all objects.
Definition: any.h:39
virtual const std::string & class_name() const
The name of this class.
Definition: jcb_ed.cc:184
bool state_is_read_write_accessible() const
True if this is attached and if the state is accessible for read and write or access control is disab...
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)
Abstract jacobian class (volatile version).
Definition: jcb.h:54
An index within the external ("client") scope of a given id space.
Definition: scoped_index.h:116
static host_type & new_host(namespace_type &xns, const poset_path &xhost_path, const poset_path &xschema_path, const poset_path &xdomain_path, const poset_path &xrange_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: jcb_ed.cc:367
virtual jcb_ed & operator=(const abstract_poset_member &xother)
Assignment operator; synonym for attach_to_state(&xother).
Definition: jcb_ed.cc:562
std::string poset_name() const
The poset name part of the path.
Definition: poset_path.cc:473
bool contains_path(const poset_path &xpath, bool xauto_access=true) const
True if this contains the poset or poset member specified by xpath.
bool invariant() const
Class invariant.
Definition: jcb_ed.cc:784
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. ...
virtual const volatile_type & lite_prototype() const
Virtual constructor for the associated volatile type.
Definition: jcb_ed.cc:618
bool is_ancestor_of(const any *xother) const
True if xother conforms to current.
Definition: jcb_ed.cc:760
jcb_ed_lite()
Default constructor.
Definition: jcb_ed.cc:49
bool empty() const
True if both poset name and member name are empty.
Definition: poset_path.cc:291
bool contains_poset(pod_index_type xhub_id, bool xauto_access=true) const
True if this contains a poset with hub id xhub_id..
jcb_ed_lite & operator=(const jcb_ed_lite &xother)
Assignment operator.
Definition: jcb_ed.cc:79
poset_path scalar_space_path() const
The path of the underlying space of scalars.
Definition: vd_space.cc:250
An abstract vector space viewed as an antisymmetric tensor space of degree 1.
Definition: at1_space.h:42
static const poset_path & standard_schema_path()
The path to the standard schema for this class.
Definition: jcb_ed.cc:317
An abstract space of Jacobians.
Definition: jcb_space.h:46
~jcb_ed()
Destructor.
Definition: jcb_ed.cc:605
int_type pod_index_type
The plain old data index type.
Definition: pod_types.h:49
jcb_ed()
Default constructor.
Definition: jcb_ed.cc:440
Abstract jacobian for d dimensional Euclidean space (persistent version).
Definition: jcb_ed.h:185
An abstract client handle for a member of a poset.
virtual jcb_ed_lite * clone() const
Virtual constructor, makes a new instance of the same type as this.
Definition: jcb_ed.cc:222
Namespace for the fiber_bundles component of the sheaf system.
Row dofs type for class vd.
Definition: vd.h:61
virtual volatile_type * lite_type() const
Virtual conversion to the associated volatile type.
Definition: jcb_ed.cc:636
A client handle for a poset member which has been prepared for use as a schema.
virtual bool is_ancestor_of(const any_lite &xother) const
Conformance test; true if other conforms to this.
Definition: jcb_ed.cc:255
pod_type hub_pod() const
The pod value of this mapped to the unglued hub id space.
Definition: scoped_index.h:710