NTRT Simulator  Version: Master
 All Classes Namespaces Files Functions Variables Typedefs Friends Pages
tgSpringCableActuatorSensorInfo.cpp
Go to the documentation of this file.
1 /*
2  * Copyright © 2012, United States Government, as represented by the
3  * Administrator of the National Aeronautics and Space Administration.
4  * All rights reserved.
5  *
6  * The NASA Tensegrity Robotics Toolkit (NTRT) v1 platform is licensed
7  * under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * http://www.apache.org/licenses/LICENSE-2.0.
11  *
12  * Unless required by applicable law or agreed to in writing,
13  * software distributed under the License is distributed on an
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
15  * either express or implied. See the License for the specific language
16  * governing permissions and limitations under the License.
17 */
18 
27 // This module
29 // Other includes from NTRTsim
32 #include "core/tgSenseable.h"
33 #include "core/tgCast.h"
34 // Other includes from the C++ standard library
35 #include <stdexcept>
36 
41 {
42 }
43 
48 {
49 }
50 
55 {
56  // The following cast will return 0 if the senseable
57  // is not a tgSpringCableActuator.
58  tgSpringCableActuator* m_pRod =
59  tgCast::cast<tgSenseable, tgSpringCableActuator>(pSenseable);
60  if( m_pRod == 0 )
61  return 0;
62  else {
63  return 1;
64  }
65 }
66 
71 {
72  //CHECK: the caller SHOULD HAVE made sure that pSenseable
73  // was a tgSpringCableActuator pointer. If not, complain!!
74  if (!isThisMySenseable(pSenseable)) {
75  throw std::invalid_argument("pSenseable is NOT a tgSpringCableActuator, inside tgSpringCableActuatorSensorInfo.");
76  }
77  // Create the list we'll return
78  std::vector<tgSensor*> newSensors;
79  // Then, if the program hasn't quit, make the sensor.
80  // Note that we cast the pointer here, knowing that it will succeed.
81  newSensors.push_back( new tgSpringCableActuatorSensor( tgCast::cast<tgSenseable, tgSpringCableActuator>(pSenseable) ));
82  return newSensors;
83 }
Constains definition of concrete class tgSpringCableActuatorSensor.
virtual std::vector< tgSensor * > createSensorsIfAppropriate(tgSenseable *pSenseable)
Utility class for class casting and filtering collections by type.
Contains the definition of abstract base class tgSpringCableActuator. Assumes that the string is line...
Definition of concrete class tgSpringCableActuatorSensorInfo.
virtual bool isThisMySenseable(tgSenseable *pSenseable)
Constains the implementation of mixin class tgSenseable.