-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhtn_task_list.cpp
More file actions
120 lines (103 loc) · 3.12 KB
/
htn_task_list.cpp
File metadata and controls
120 lines (103 loc) · 3.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#include <string>
#include <vector>
#include <sstream>
#include <set>
#include <tr1/memory>
#include "exception.hpp"
#include "funcs.hpp"
#include "term.hpp"
#include "term_string.hpp"
#include "term_constant.hpp"
#include "term_variable.hpp"
#include "type_table.hpp"
#include "substitution.hpp"
#include "formula.hpp"
#include "formula_pred.hpp"
#include "formula_neg.hpp"
#include "formula_conj.hpp"
#include "htn_task_head.hpp"
#include "htn_task_descr.hpp"
#include "operator.hpp"
#include "htn_method.hpp"
#include "htn_domain.hpp"
#include "htn_task_list.hpp"
/** \file htn_task_list.hpp
* Declaration of HtnTaskList class.
*/
/** \file htn_task_list.cpp
* Definition of HtnTaskList class.
*/
/** \class HtnTaskList
* A collection of smart pointers to HtnTaskDescr objects.
*/
/** \var HtnTaskList::m_sName
* The name of this task list.
*/
/** \var HtnTaskList::m_pDomain
* The HtnDomain for which these tasks will be used.
* From this we can get typing and other information.
*/
/**
* Construct an HtnTaskList from an associated domain and textual description.
* \param p_pDomain IN A pointer to the domain associated with these tasks.
* \param p_sString IN A textual representation of the list of tasks.
*/
HtnTaskList::HtnTaskList( const std::tr1::shared_ptr< HtnDomain > & p_pDomain,
std::string p_sString )
: m_pDomain( p_pDomain )
{
std::stringstream l_sStream( p_sString );
EatWhitespace( l_sStream );
EatString( l_sStream, "(" );
EatWhitespace( l_sStream );
EatString( l_sStream, "define" );
EatWhitespace( l_sStream );
EatString( l_sStream, "(" );
EatWhitespace( l_sStream );
EatString( l_sStream, "tasks" );
EatWhitespace( l_sStream );
while( l_sStream.peek() != ' ' && l_sStream.peek() != '\t' &&
l_sStream.peek() != '\n' && l_sStream.peek() != '\r' &&
l_sStream.peek() != ')' && l_sStream.peek() != '(' )
m_sName += l_sStream.get();
EatWhitespace( l_sStream );
EatString( l_sStream, ")" );
EatWhitespace( l_sStream );
while( l_sStream.peek() == '(' )
{
push_back( std::tr1::shared_ptr< HtnTaskDescr >( new HtnTaskDescr( l_sStream, m_pDomain->GetAllowableTypes(), m_pDomain->GetAllowablePredicates() ) ) );
EatWhitespace( l_sStream );
}
EatString( l_sStream, ")" );
}
/**
* Construct an HtnTaskList as a copy of an existing one.
* I cannot use the base class copy constructor because it would be a
* shallow copy of the pointers to tasks.
* \param p_Other IN The existing HtnTaskList to copy.
*/
HtnTaskList::HtnTaskList( const HtnTaskList & p_Other )
: std::vector< std::tr1::shared_ptr< HtnTaskDescr > >( p_Other ),
m_pDomain( p_Other.m_pDomain )
{
m_sName = p_Other.m_sName;
m_pDomain = p_Other.m_pDomain;
}
/**
* Destruct an HtnTaskList.
*/
HtnTaskList::~HtnTaskList()
{
}
size_t HtnTaskList::GetMemSizeMin() const
{
size_t l_iSize = sizeof( HtnTaskList ) + m_sName.capacity() + capacity() * sizeof( std::tr1::shared_ptr< HtnTaskDescr > );
return l_iSize;
}
size_t HtnTaskList::GetMemSizeMax() const
{
size_t l_iSize = GetMemSizeMin();
for( unsigned int i = 0; i < size(); i++ )
l_iSize += at( i )->GetMemSizeMax();
return l_iSize;
}