NTRT Simulator
 All Classes Files Functions Variables Typedefs Friends Pages
tgBuildSpec.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 
26 #include "tgBuildSpec.h"
27 #include "tgRigidInfo.h"
28 #include "tgConnectorInfo.h"
29 
30 #include "core/tgException.h"
31 #include "core/tgTags.h"
32 #include "core/tgTagSearch.h"
33 
34 tgBuildSpec::RigidAgent::~RigidAgent()
35 {
36  delete infoFactory;
37 }
38 tgBuildSpec::ConnectorAgent::~ConnectorAgent()
39 {
40  delete infoFactory;
41 }
42 
43 tgBuildSpec::~tgBuildSpec() {
44  while (!m_rigidAgents.empty()){
45  RigidAgent* agent = m_rigidAgents.back();
46  m_rigidAgents.pop_back();
47  delete agent;
48  }
49  while (!m_connectorAgents.empty()){
50  ConnectorAgent* agent = m_connectorAgents.back();
51  m_connectorAgents.pop_back();
52  delete agent;
53  }
54 }
55 
56 void tgBuildSpec::addBuilder(std::string tag_search, tgRigidInfo* infoFactory)
57 {
58  // Note: we could try to check that search strings are different here,
59  // but we're going to defer that until the build phase due to the
60  // large possibility of unhandled edge cases (e.g. 'a b c' matches some
61  // of the same things as 'a b'. Also, 'a|b|c -c' === 'a|b -c', and it
62  // goes downhill from there. tgTagSearch should be able to handle that,
63  // but user messaging would be difficult here.)
64 
65  //m_infoFactorys.push_back(tgBuildSpec::Entry(tgTagSearch(tag_search), infoFactory)); // @todo: make this work
66  m_rigidAgents.push_back(new RigidAgent(tag_search, infoFactory));
67 }
68 
69 void tgBuildSpec::addBuilder(std::string tag_search, tgConnectorInfo* infoFactory)
70 {
71  m_connectorAgents.push_back(new ConnectorAgent(tag_search, infoFactory));
72 }
73 
Contains the definition of class tgTagSearch $Id$.
Definition of abstract class tgRigidInfo.
Extension of std::exception for use within the library.
Contains the definition of class tgTags $Id$.
Definition of class tgConnectorInfo.
Definition of class tgBuildSpec.