Simbody
|
00001 #ifndef SimTK_SimTKCOMMON_STUDY_H_ 00002 #define SimTK_SimTKCOMMON_STUDY_H_ 00003 00004 /* -------------------------------------------------------------------------- * 00005 * SimTK Core: SimTKcommon * 00006 * -------------------------------------------------------------------------- * 00007 * This is part of the SimTK Core biosimulation toolkit originating from * 00008 * Simbios, the NIH National Center for Physics-Based Simulation of * 00009 * Biological Structures at Stanford, funded under the NIH Roadmap for * 00010 * Medical Research, grant U54 GM072970. See https://simtk.org. * 00011 * * 00012 * Portions copyright (c) 2006-7 Stanford University and the Authors. * 00013 * Authors: Michael Sherman * 00014 * Contributors: * 00015 * * 00016 * Permission is hereby granted, free of charge, to any person obtaining a * 00017 * copy of this software and associated documentation files (the "Software"), * 00018 * to deal in the Software without restriction, including without limitation * 00019 * the rights to use, copy, modify, merge, publish, distribute, sublicense, * 00020 * and/or sell copies of the Software, and to permit persons to whom the * 00021 * Software is furnished to do so, subject to the following conditions: * 00022 * * 00023 * The above copyright notice and this permission notice shall be included in * 00024 * all copies or substantial portions of the Software. * 00025 * * 00026 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * 00027 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * 00028 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * 00029 * THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * 00030 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * 00031 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE * 00032 * USE OR OTHER DEALINGS IN THE SOFTWARE. * 00033 * -------------------------------------------------------------------------- */ 00034 00035 #include "SimTKcommon/basics.h" 00036 #include "SimTKcommon/Simmatrix.h" 00037 #include "SimTKcommon/internal/State.h" 00038 #include "SimTKcommon/internal/System.h" 00039 00040 namespace SimTK { 00041 00042 /* TODO: THIS CLASS IS NOT CURRENTLY USED AND IS JUST A SKELETON. 00043 * PLEASE IGNORE FOR NOW. 00044 * 00045 * The handle class which serves as the abstract parent of all Studies. 00046 * 00047 * There are two distinct users of this class: 00048 * - Study Users: people who are making use of a concrete Study (which will 00049 * inherit methods from this class) 00050 * - Study Developers: people who are writing concrete Study classes 00051 * 00052 * Only methods intended for Study Users and a few bookkeeping methods 00053 * are in the main Study class, which is a SimTK Handle class, meaning 00054 * that it consists only of a single pointer, which points to a 00055 * Study::Guts class. The Guts class is abstract, and virtual methods 00056 * to be implemented by Study Developers in the concrete 00057 * Study are defined there, along 00058 * with other utilities of use to the concrete Study Developer but 00059 * not to the end user. The Guts class is declared in a separate 00060 * header file, and only people who are writing their own Study 00061 * classes need look there. 00062 */ 00063 00064 class SimTK_SimTKCOMMON_EXPORT Study { 00065 public: 00066 class Guts; // local; name is Study::Guts 00067 friend class Guts; 00068 private: 00069 // This is the only data member in this class. Also, any class derived from 00070 // Study must have *NO* data members at all (data goes in the Guts class). 00071 Guts* guts; 00072 public: 00073 Study() : guts(0) { } 00074 Study(const Study&); 00075 Study& operator=(const Study&); 00076 ~Study(); 00077 00078 explicit Study(const System& sys); 00079 00080 const String& getName() const; 00081 const String& getVersion() const; 00082 00083 const System& getSystem() const; 00084 const State& getState() const; 00085 State& updState(); 00086 00089 bool isOwnerHandle() const; 00090 bool isEmptyHandle() const; 00091 00092 00093 // There can be multiple handles on the same Study. 00094 bool isSameStudy(const Study& otherStudy) const; 00095 00096 // Internal use only 00097 00098 // dynamic_cast the returned reference to a reference to your concrete Guts 00099 // class. 00100 const Study::Guts& getStudyGuts() const {assert(guts); return *guts;} 00101 Study::Guts& updStudyGuts() {assert(guts); return *guts;} 00102 00103 // Put new *unowned* Guts into this *empty* handle and take over ownership. 00104 // If this handle is already in use, or if Guts is already owned this 00105 // routine will throw an exception. 00106 void adoptStudyGuts(Study::Guts* g); 00107 00108 explicit Study(Study::Guts* g) : guts(g) { } 00109 bool hasGuts() const {return guts!=0;} 00110 }; 00111 00112 } // namespace SimTK 00113 00114 #endif // SimTK_SimTKCOMMON_STUDY_H_