MOOSE - Multiscale Object Oriented Simulation Environment
|
#include "header.h"
#include <stdio.h>
#include "Neutral.h"
#include "Shell.h"
#include "Wildcard.h"
Go to the source code of this file.
Functions | |
bool | alignedSingleWildcardMatch (const string &name, const string &wild) |
int | allChildren (ObjId start, unsigned int index, const string &insideBrace, vector< ObjId > &ret) |
static unsigned int | findBraceContent (const string &path, string &beforeBrace, string &insideBrace) |
unsigned int | findWithSingleCharWildcard (const string &name, unsigned int start, const string &wild) |
static int | innerFind (const string &path, vector< ObjId > &ret) |
bool | matchBeforeBrace (ObjId id, const string &wild) |
static bool | matchInsideBrace (ObjId id, const string &inside) |
static bool | matchName (ObjId id, unsigned int index, const string &beforeBrace, const string &insideBrace) |
static void | myUnique (vector< ObjId > &ret) |
int | simpleWildcardFind (const string &path, vector< ObjId > &ret) |
int | singleLevelWildcard (ObjId start, const string &path, vector< ObjId > &ret) |
void | testWildcard () |
static bool | wildcardFieldComparison (ObjId oid, const string &mid) |
int | wildcardFind (const string &path, vector< ObjId > &ret) |
static int | wildcardRelativeFind (ObjId start, const vector< string > &path, unsigned int depth, vector< ObjId > &ret) |
void | wildcardTestFunc (ObjId *elist, unsigned int ne, const string &path) |
bool alignedSingleWildcardMatch | ( | const string & | name, |
const string & | wild | ||
) |
Returns true if the name matches the wildcard string. Doesn't care about following characters in 'name'. Single character wildcards are indicated with '?'
Definition at line 383 of file Wildcard.cpp.
Referenced by findWithSingleCharWildcard(), and testWildcard().
int allChildren | ( | ObjId | start, |
unsigned int | index, | ||
const string & | insideBrace, | ||
vector< ObjId > & | ret | ||
) |
Recursive function to compare all descendants and cram matches into ret. Returns number of matches.
Definition at line 495 of file Wildcard.cpp.
References allChildren(), ALLDATA, Neutral::children(), ObjId::dataIndex, ObjId::eref(), and matchInsideBrace().
Referenced by allChildren(), moose::CompartmentBase::setGeomAndElec(), and singleLevelWildcard().
|
static |
Parses the name and separates out the stuff before the brace, the stuff inside it, and if present, the index which is also in a brace. Returns the index, and if not found, zero. Assume order is foo[index][insideBrace] or foo[index] or foo[insideBrace] or foo
Note that for the index, an empty [] means ALLDATA, but the absence of the braces altogether means zero.
Note also that if the name ends in the wildcard '#', then we assume that all indices are OK, unless overridden by a subsequent specific index via braces. So foo# gives all indices but foo#[3] only gives index == 3.
Definition at line 243 of file Wildcard.cpp.
References ALLDATA, and Shell::chopString().
Referenced by singleLevelWildcard(), and testWildcard().
unsigned int findWithSingleCharWildcard | ( | const string & | name, |
unsigned int | start, | ||
const string & | wild | ||
) |
Returns start index for match between string and wildcard using '?' to indicate single character matches. Scans forward along 'name' until it finds a match, or gives up. The entire wildcard must be matched, otherwise returns ~0U findWithSingleCharWildcard( "abc", 0, "a?c" ): return 0; findWithSingleCharWildcard( "xyzabc", 1, "a?c" ): return 3; findWithSingleCharWildcard( "xyzabb", 1, "a?c" ): return ~0U;
Definition at line 405 of file Wildcard.cpp.
References alignedSingleWildcardMatch().
Referenced by matchBeforeBrace(), and testWildcard().
|
static |
Does the wildcard find on a single path
Definition at line 89 of file Wildcard.cpp.
References Shell::chopString(), ObjId::data(), Shell::getCwe(), and wildcardRelativeFind().
Referenced by simpleWildcardFind().
bool matchBeforeBrace | ( | ObjId | id, |
const string & | wild | ||
) |
matchBeforeBrace checks to see if the wildcard string 'name' matches up with the name of the id. Rules:
It substitutes for any number of characters.
? may be used any number of times in the wildcard, and must substitute exactly for characters.
If bracesInName, then the Id name itself includes braces.
Definition at line 432 of file Wildcard.cpp.
References Shell::chopString(), and findWithSingleCharWildcard().
Referenced by Neuron::getSpinesFromExpression(), matchName(), and testWildcard().
|
static |
matchInsideBrace checks for element property matches Still has some legacy hacks for reading GENESIS code.
Definition at line 322 of file Wildcard.cpp.
References ALLDATA, dataIndex, and wildcardFieldComparison().
Referenced by allChildren(), matchName(), and testWildcard().
|
static |
Compares the various parts of the wildcard name with the id Indexing is messy here because we may refer to any of 3 things:
Definition at line 293 of file Wildcard.cpp.
References matchBeforeBrace(), and matchInsideBrace().
Referenced by singleLevelWildcard().
|
static |
Definition at line 152 of file Wildcard.cpp.
Referenced by wildcardFind().
int simpleWildcardFind | ( | const string & | path, |
vector< ObjId > & | ret | ||
) |
This is the basic wildcardFind function, working on a single tree. It adds entries into the vector 'ret' with Ids found according to the path string. It preserves the order of the returned Ids as the order of elements traversed in the search. It does NOT eliminate duplicates. This is a depth-first search. Note that it does the dumb but backward compatible thing with Ids of arrays: it lists every entry.
It returns the number of Ids found here.
Definition at line 137 of file Wildcard.cpp.
References Shell::chopString(), and innerFind().
Referenced by setMethod(), Dsolve::setPath(), testWildcard(), wildcardFind(), and wildcardTestFunc().
singleLevelWildcard parses a single level of the path and returns all ids that match it. If there is a suitable doublehash, it will recurse into child elements. Returns # of ids found.
Definition at line 183 of file Wildcard.cpp.
References allChildren(), ALLDATA, Neutral::children(), ObjId::dataIndex, ObjId::eref(), findBraceContent(), and matchName().
Referenced by wildcardRelativeFind().
void testWildcard | ( | ) |
Definition at line 591 of file Wildcard.cpp.
References alignedSingleWildcardMatch(), ALLDATA, Eref::data(), Shell::doCreate(), Shell::doDelete(), Id::eref(), findBraceContent(), findWithSingleCharWildcard(), matchBeforeBrace(), matchInsideBrace(), name, Field< A >::set(), simpleWildcardFind(), and wildcardTestFunc().
Referenced by testMpiShell(), and testShell().
|
static |
wildcardFieldComparison returns true if the value of the specified field matches the value in the comparsion string mid. Format is FIELD(name)=val If the format or the value does not match, return 0
Definition at line 35 of file Wildcard.cpp.
References op(), and SetGet::strGet().
Referenced by matchInsideBrace().
int wildcardFind | ( | const string & | n, |
vector< ObjId > & | ret | ||
) |
wildcardFind returns the number of Ids found. This behaves the same as simpleWildcardFind, except that it eliminates non-unique entries, and in the process will scramble the ordering.
Definition at line 169 of file Wildcard.cpp.
References myUnique(), and simpleWildcardFind().
Referenced by Neuron::buildElist(), doClassSpecificMessaging(), Shell::doStart(), ReadKkit::dumpPlots(), Neuron::getExprElist(), Neuron::getExprVal(), Shell::innerUseClock(), moose_wildcardFind(), Stoich::setPath(), Dsolve::setStoich(), NeuroMesh::setSubTreePath(), writeGroup(), and writeKkit().
|
static |
This is the main recursive function of the wildcarding scheme. It builds a wildcard list based on path. Puts found Ids into ret, and returns # found. The start ObjId is one that already matches. depth is the position on the path. This should work for multi-node wildcard searches since it only refers to messaging and basic Element information that is present on all nodes.
Definition at line 544 of file Wildcard.cpp.
References singleLevelWildcard().
Referenced by innerFind().
void wildcardTestFunc | ( | ObjId * | elist, |
unsigned int | ne, | ||
const string & | path | ||
) |
Definition at line 567 of file Wildcard.cpp.
References ObjId::element(), Element::getName(), and simpleWildcardFind().
Referenced by testWildcard().