Simbody  3.4 (development)
Study.h
Go to the documentation of this file.
00001 #ifndef SimTK_SimTKCOMMON_STUDY_H_
00002 #define SimTK_SimTKCOMMON_STUDY_H_
00003 
00004 /* -------------------------------------------------------------------------- *
00005  *                       Simbody(tm): SimTKcommon                             *
00006  * -------------------------------------------------------------------------- *
00007  * This is part of the SimTK 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/home/simbody.  *
00011  *                                                                            *
00012  * Portions copyright (c) 2006-12 Stanford University and the Authors.        *
00013  * Authors: Michael Sherman                                                   *
00014  * Contributors:                                                              *
00015  *                                                                            *
00016  * Licensed under the Apache License, Version 2.0 (the "License"); you may    *
00017  * not use this file except in compliance with the License. You may obtain a  *
00018  * copy of the License at http://www.apache.org/licenses/LICENSE-2.0.         *
00019  *                                                                            *
00020  * Unless required by applicable law or agreed to in writing, software        *
00021  * distributed under the License is distributed on an "AS IS" BASIS,          *
00022  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   *
00023  * See the License for the specific language governing permissions and        *
00024  * limitations under the License.                                             *
00025  * -------------------------------------------------------------------------- */
00026 
00027 #include "SimTKcommon/basics.h"
00028 #include "SimTKcommon/Simmatrix.h"
00029 #include "SimTKcommon/internal/State.h"
00030 #include "SimTKcommon/internal/System.h"
00031 
00032 namespace SimTK {
00033 
00034 /* TODO: THIS CLASS IS NOT CURRENTLY USED AND IS JUST A SKELETON.
00035  *       PLEASE IGNORE FOR NOW.
00036  *
00037  * The handle class which serves as the abstract parent of all Studies.
00038  *
00039  * There are two distinct users of this class:
00040  *   - Study Users: people who are making use of a concrete Study (which will
00041  *     inherit methods from this class)
00042  *   - Study Developers: people who are writing concrete Study classes
00043  *
00044  * Only methods intended for Study Users and a few bookkeeping methods
00045  * are in the main Study class, which is a SimTK Handle class, meaning
00046  * that it consists only of a single pointer, which points to a 
00047  * Study::Guts class. The Guts class is abstract, and virtual methods
00048  * to be implemented by Study Developers in the concrete
00049  * Study are defined there, along
00050  * with other utilities of use to the concrete Study Developer but
00051  * not to the end user. The Guts class is declared in a separate
00052  * header file, and only people who are writing their own Study
00053  * classes need look there.
00054  */
00055 
00056 class SimTK_SimTKCOMMON_EXPORT Study {
00057 public:
00058     class Guts; // local; name is Study::Guts
00059     friend class Guts;
00060 private:
00061     // This is the only data member in this class. Also, any class derived from
00062     // Study must have *NO* data members at all (data goes in the Guts class).
00063     Guts* guts;
00064 public:
00065     Study() : guts(0) { }
00066     Study(const Study&);
00067     Study& operator=(const Study&);
00068     ~Study();
00069 
00070     explicit Study(const System& sys);
00071 
00072     const String& getName()    const;
00073     const String& getVersion() const;
00074 
00075     const System& getSystem() const;
00076     const State&  getState()  const;
00077     State&        updState();
00078 
00081     bool isOwnerHandle() const;
00082     bool isEmptyHandle() const;
00083 
00084 
00085     // There can be multiple handles on the same Study.
00086     bool isSameStudy(const Study& otherStudy) const;
00087 
00088     // Internal use only
00089 
00090     // dynamic_cast the returned reference to a reference to your concrete Guts
00091     // class.
00092     const Study::Guts& getStudyGuts() const {assert(guts); return *guts;}
00093     Study::Guts&       updStudyGuts()       {assert(guts); return *guts;}
00094 
00095     // Put new *unowned* Guts into this *empty* handle and take over ownership.
00096     // If this handle is already in use, or if Guts is already owned this
00097     // routine will throw an exception.
00098     void adoptStudyGuts(Study::Guts* g);
00099 
00100     explicit Study(Study::Guts* g) : guts(g) { }
00101     bool hasGuts() const {return guts!=0;}
00102 };
00103 
00104 } // namespace SimTK
00105 
00106 #endif // SimTK_SimTKCOMMON_STUDY_H_
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines