35 template <
typename GUM_SCALAR >
40 __o3_prm(&o3_prm), __errors(&errors) {
44 template <
typename GUM_SCALAR >
55 template <
typename GUM_SCALAR >
67 template <
typename GUM_SCALAR >
72 template <
typename GUM_SCALAR >
75 if (
this == &src) {
return *
this; }
87 template <
typename GUM_SCALAR >
90 if (
this == &src) {
return *
this; }
91 __prm = std::move(src.__prm);
102 template <
typename GUM_SCALAR >
105 if (name.
label() ==
"") {
return true; }
128 if (t->name().label() == name.
label()) {
135 if (i->name().label() == name.
label()) {
142 if (c->name().label() == name.
label()) {
148 auto lookup =
"." + name.
label();
150 auto matches = std::vector< std::string >();
153 for (
auto t :
__prm->types()) {
155 if (!found.exists(t->name())) {
157 matches.push_back(t->name());
163 if (
endsWith(t->name().label(), lookup)) {
164 if (!found.exists(t->name().label())) {
165 found.
insert(t->name().label());
166 matches.push_back(t->name().label());
172 for (
auto i :
__prm->interfaces()) {
174 if (!found.exists(i->name())) {
176 matches.push_back(i->name());
182 if (
endsWith(i->name().label(), lookup)) {
183 if (!found.exists(i->name().label())) {
184 found.
insert(i->name().label());
185 matches.push_back(i->name().label());
191 for (
auto c :
__prm->classes()) {
193 if (!found.exists(c->name())) {
195 matches.push_back(c->name());
201 if (
endsWith(c->name().label(), lookup)) {
202 if (!found.exists(c->name().label())) {
203 found.
insert(c->name().label());
204 matches.push_back(c->name().label());
209 if (matches.
size() == 1) {
211 name.
label() = matches.back();
214 }
else if (matches.
size() == 0) {
217 O3PRM_TYPE_NOT_FOUND(name, *
__errors);
223 O3PRM_TYPE_AMBIGUOUS(name, matches, *
__errors);
228 template <
typename GUM_SCALAR >
231 if (name.
label() ==
"") {
return true; }
247 if (t->name().label() == name.
label()) {
255 auto lookup =
"." + name.
label();
257 auto matches = std::vector< std::string >();
260 for (
auto t :
__prm->types()) {
262 if (!found.exists(t->name())) {
264 matches.push_back(t->name());
271 if (
endsWith(t->name().label(), lookup)) {
272 if (!found.exists(t->name().label())) {
273 found.
insert(t->name().label());
274 matches.push_back(t->name().label());
279 if (matches.
size() == 1) {
281 name.
label() = matches.back();
284 }
else if (matches.
size() == 0) {
287 O3PRM_TYPE_NOT_FOUND(name, *
__errors);
293 O3PRM_TYPE_AMBIGUOUS(name, matches, *
__errors);
298 template <
typename GUM_SCALAR >
301 if (name.
label() ==
"") {
return true; }
316 if (i->name().label() == name.
label()) {
324 auto lookup =
"." + name.
label();
326 auto matches = std::vector< std::string >();
329 for (
auto i :
__prm->interfaces()) {
331 if (!found.exists(i->name())) {
333 matches.push_back(i->name());
340 if (
endsWith(i->name().label(), lookup)) {
341 if (!found.exists(i->name().label())) {
342 found.
insert(i->name().label());
343 matches.push_back(i->name().label());
348 if (matches.
size() == 1) {
351 name.
label() = matches.back();
354 }
else if (matches.
size() == 0) {
357 O3PRM_INTERFACE_NOT_FOUND(name, *
__errors);
363 O3PRM_INTERFACE_AMBIGUOUS(name, matches, *
__errors);
368 template <
typename GUM_SCALAR >
371 if (name.
label() ==
"") {
return true; }
386 if (c->name().label() == name.
label()) {
394 auto lookup =
"." + name.
label();
395 auto matches = std::vector< std::string >();
399 for (
auto c :
__prm->classes()) {
401 if (!found.exists(c->name())) {
402 found.insert(c->name());
403 matches.push_back(c->name());
410 if (
endsWith(c->name().label(), lookup)) {
411 if (!found.exists(c->name().label())) {
412 found.insert(c->name().label());
413 matches.push_back(c->name().label());
418 if (matches.size() == 1) {
421 name.
label() = matches.back();
424 }
else if (matches.size() == 0) {
427 O3PRM_CLASS_NOT_FOUND(name, *
__errors);
433 O3PRM_CLASS_AMBIGUOUS(name, matches, *
__errors);
438 template <
typename GUM_SCALAR >
441 if (name.
label() ==
"") {
return true; }
455 if (i->name().label() == name.
label()) {
463 if (c->name().label() == name.
label()) {
471 auto lookup =
"." + name.
label();
473 auto matches = std::vector< std::string >();
476 for (
auto i :
__prm->interfaces()) {
478 if (!found.exists(i->name())) {
480 matches.push_back(i->name());
487 if (
endsWith(i->name().label(), lookup)) {
488 if (!found.exists(i->name().label())) {
489 found.
insert(i->name().label());
490 matches.push_back(i->name().label());
496 for (
auto c :
__prm->classes()) {
498 if (!found.exists(c->name())) {
500 matches.push_back(c->name());
507 if (
endsWith(c->name().label(), lookup)) {
508 if (!found.exists(c->name().label())) {
509 found.
insert(c->name().label());
510 matches.push_back(c->name().label());
515 if (matches.
size() == 1) {
518 name.
label() = matches.back();
521 }
else if (matches.
size() == 0) {
524 O3PRM_REFERENCE_NOT_FOUND(name, *
__errors);
530 O3PRM_REFERENCE_AMBIGUOUS(name, matches, *
__errors);
bool exists(const Key &key) const
Checks whether there exists an element with a given key in the hashtable.
Headers for the O3NameSolver class.
This class is used contain and manipulate gum::ParseError.
The O3Label is part of the AST of the O3PRM language.
bool resolveType(O3Label &name)
gum is the global namespace for all aGrUM entities
bool endsWith(std::string const &value, std::string const &ending)
Returns true if value ends with ending.
O3NameSolver< GUM_SCALAR > & operator=(const O3NameSolver< GUM_SCALAR > &src)
Resolves names for the different O3PRM factories.
bool resolveClassElement(O3Label &name)
bool resolveSlotType(O3Label &name)
O3InterfaceList & interfaces()
O3NameSolver(PRM< GUM_SCALAR > &prm, O3PRM &o3_prm, ErrorsContainer &errors)
This class represents a Probabilistic Relational PRMSystem<GUM_SCALAR>.
ErrorsContainer * __errors
bool resolveInterface(O3Label &name)
The O3PRM is part of the AST of the O3PRM language.
Size size() const noexcept
Returns the number of elements in the set.
value_type & insert(const Key &key, const Val &val)
Adds a new element (actually a copy of this element) into the hash table.
void insert(const Key &k)
Inserts a new element into the set.
bool resolveClass(O3Label &name)
PRM< GUM_SCALAR > * __prm