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