NTRT Simulator  Version: Master
 All Classes Namespaces Files Functions Variables Typedefs Friends Pages
tgPort.cpp
Go to the documentation of this file.
1 /*
2  * Copyright © 2014, 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 
25 // Sample application
26 #include "dev/steve/T12SuperBallPayload.h"
27 #include "dev/steve/T12SuperBallPayloadController.h"
28 // This library
29 #include "core/tgModel.h"
30 // The C++ Standard Library
31 #include <iostream>
32 #include <string>
33 
41 // Exports JSON of tg to file
42 void exportJSON(string filename, tgModel* tg);
43 
44 // Returns tgModel stored in provided file
45 // Assumes file is in JSON format
46 tgModel *importJSON(string filename);
47 
48 int main(int argc, char** argv)
49 {
50  T12SuperBallPayload* myModel = new T12SuperBallPayload(); //Note: model can no longer be const
51 
52  SuperBallPrefLengthController* pTC = new SuperBallPrefLengthController(9); //Note: controller can no longer be const
53  myModel->attach(pTC);
54 
55  // DEMO
56  string filename = "tgData.json";
57  myModel = (T12SuperBallPayload *) importJSON(filename); //TODO: copy constructor?
58  exportJSON(filename, myModel);
59 
60  return 0;
61 }
62 
63 void exportJSON(string filename, tgModel* tg) {
64  cout << "\"Exporting JSON of tg to " + filename + "\"" << endl;
65 }
66 
67 tgModel *importJSON(string filename) {
68  cout << "\"Importing JSON from " + filename + "\"" << endl;
69 
70  return NULL;
71 }
72 
int main(int argc, char **argv)
Contains the definition of class tgModel.
void attach(tgObserver< T > *pObserver)
Definition: tgSubject.h:91
void exportJSON(string filename, tgModel *tg)
Definition: tgPort.cpp:63