Simbody  3.5
Study.h
Go to the documentation of this file.
1 #ifndef SimTK_SimTKCOMMON_STUDY_H_
2 #define SimTK_SimTKCOMMON_STUDY_H_
3 
4 /* -------------------------------------------------------------------------- *
5  * Simbody(tm): SimTKcommon *
6  * -------------------------------------------------------------------------- *
7  * This is part of the SimTK biosimulation toolkit originating from *
8  * Simbios, the NIH National Center for Physics-Based Simulation of *
9  * Biological Structures at Stanford, funded under the NIH Roadmap for *
10  * Medical Research, grant U54 GM072970. See https://simtk.org/home/simbody. *
11  * *
12  * Portions copyright (c) 2006-12 Stanford University and the Authors. *
13  * Authors: Michael Sherman *
14  * Contributors: *
15  * *
16  * Licensed under the Apache License, Version 2.0 (the "License"); you may *
17  * not use this file except in compliance with the License. You may obtain a *
18  * copy of the License at http://www.apache.org/licenses/LICENSE-2.0. *
19  * *
20  * Unless required by applicable law or agreed to in writing, software *
21  * distributed under the License is distributed on an "AS IS" BASIS, *
22  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
23  * See the License for the specific language governing permissions and *
24  * limitations under the License. *
25  * -------------------------------------------------------------------------- */
26 
27 #include "SimTKcommon/basics.h"
28 #include "SimTKcommon/Simmatrix.h"
31 
32 namespace SimTK {
33 
34 /* TODO: THIS CLASS IS NOT CURRENTLY USED AND IS JUST A SKELETON.
35  * PLEASE IGNORE FOR NOW.
36  *
37  * The handle class which serves as the abstract parent of all Studies.
38  *
39  * There are two distinct users of this class:
40  * - Study Users: people who are making use of a concrete Study (which will
41  * inherit methods from this class)
42  * - Study Developers: people who are writing concrete Study classes
43  *
44  * Only methods intended for Study Users and a few bookkeeping methods
45  * are in the main Study class, which is a SimTK Handle class, meaning
46  * that it consists only of a single pointer, which points to a
47  * Study::Guts class. The Guts class is abstract, and virtual methods
48  * to be implemented by Study Developers in the concrete
49  * Study are defined there, along
50  * with other utilities of use to the concrete Study Developer but
51  * not to the end user. The Guts class is declared in a separate
52  * header file, and only people who are writing their own Study
53  * classes need look there.
54  */
55 
57 public:
58  class Guts; // local; name is Study::Guts
59  friend class Guts;
60 private:
61  // This is the only data member in this class. Also, any class derived from
62  // Study must have *NO* data members at all (data goes in the Guts class).
63  Guts* guts;
64 public:
65  Study() : guts(0) { }
66  Study(const Study&);
67  Study& operator=(const Study&);
68  ~Study();
69 
70  explicit Study(const System& sys);
71 
72  const String& getName() const;
73  const String& getVersion() const;
74 
75  const System& getSystem() const;
76  const State& getState() const;
77  State& updState();
78 
81  bool isOwnerHandle() const;
82  bool isEmptyHandle() const;
83 
84 
85  // There can be multiple handles on the same Study.
86  bool isSameStudy(const Study& otherStudy) const;
87 
88  // Internal use only
89 
90  // dynamic_cast the returned reference to a reference to your concrete Guts
91  // class.
92  const Study::Guts& getStudyGuts() const {assert(guts); return *guts;}
93  Study::Guts& updStudyGuts() {assert(guts); return *guts;}
94 
95  // Put new *unowned* Guts into this *empty* handle and take over ownership.
96  // If this handle is already in use, or if Guts is already owned this
97  // routine will throw an exception.
98  void adoptStudyGuts(Study::Guts* g);
99 
100  explicit Study(Study::Guts* g) : guts(g) { }
101  bool hasGuts() const {return guts!=0;}
102 };
103 
104 } // namespace SimTK
105 
106 #endif // SimTK_SimTKCOMMON_STUDY_H_
#define SimTK_SimTKCOMMON_EXPORT
Definition: SimTKcommon/include/SimTKcommon/internal/common.h:218
const Study::Guts & getStudyGuts() const
Definition: Study.h:92
This is the top-level SimTK namespace into which all SimTK names are placed to avoid collision with o...
Definition: Assembler.h:37
This is the declaration for the Study::Guts class, the abstract object to which a Study handle points...
Definition: StudyGuts.h:69
Study(Study::Guts *g)
Definition: Study.h:100
This object is intended to contain all state information for a SimTK::System, except topological info...
Definition: State.h:276
Study()
Definition: Study.h:65
Study::Guts & updStudyGuts()
Definition: Study.h:93
SimTK::String is a plug-compatible std::string replacement (plus some additional functionality) inten...
Definition: String.h:62
Declares the user-visible part of a SimTK::State, the implementation is done in a separate internal c...
Definition: Study.h:56
This is the base class that serves as the parent of all SimTK System objects; most commonly Simbody's...
Definition: System.h:97
bool hasGuts() const
Definition: Study.h:101
This is the header which should be included in user programs that would like to make use of all the S...
Includes internal headers providing declarations for the basic SimTK Core classes.