11 #include "../shell/Shell.h"
18 const Cinfo* baseCinfo,
26 : name_( name ), baseCinfo_( baseCinfo ), dinfo_( d ),
27 numBindIndex_( 0 ), banCreation_( banCreation )
29 if ( cinfoMap().find( name ) != cinfoMap().end() ) {
30 cout <<
"Warning: Duplicate Cinfo name " << name << endl;
32 init( finfoArray, nFinfos );
33 cinfoMap()[
name ] =
this;
37 cerr << setw(VERBOSITY) <<
"Doing initCinfo for " << name <<
" with numDoc = " << numDoc << endl;
39 if ( doc && numDoc ) {
40 for (
unsigned int i = 0; i < numDoc - 1; i += 2 ) {
41 const string argName = doc[i];
42 const string argVal = doc[i+1];
45 doc_[ argName ] = argVal;
51 : name_(
"dummy" ), baseCinfo_( 0 ), dinfo_( 0 ),
52 numBindIndex_( 0 ), banCreation_( false )
56 : name_(
"dummy" ), baseCinfo_( 0 ), dinfo_( 0 ),
57 numBindIndex_( 0 ), banCreation_( false )
91 for (
unsigned int i = 0; i < nFinfos; i++ ) {
105 assert (
funcs_.size() > fid );
118 if ( dynamic_cast< DestFinfo* >( f ) ) {
121 else if ( dynamic_cast< SrcFinfo* >( f ) ) {
124 else if ( dynamic_cast< ValueFinfoBase* >( f ) ) {
127 else if ( dynamic_cast< LookupValueFinfoBase* >( f ) ) {
130 else if ( dynamic_cast< SharedFinfo* >( f ) ) {
133 else if ( dynamic_cast< FieldElementFinfoBase* >( f ) ) {
145 for ( vector< const Finfo* >::const_iterator i =
148 (*i)->postCreationFunc( newId, newElm );
153 if ( f.size() > 0 ) {
154 char* data =
reinterpret_cast< char*
>( &f[0] );
167 vector< unsigned int > dims( 1, 0 );
169 vector< Id > cinfoElements;
170 for ( map< string, Cinfo* >::iterator i =
cinfoMap().begin();
173 char* data =
reinterpret_cast< char*
>( i->second );
180 cinfoElements.push_back(
id );
183 vector< Id >::iterator j = cinfoElements.begin();
184 for ( map< string, Cinfo* >::iterator i =
cinfoMap().begin();
202 map<string, Cinfo*>::iterator i =
cinfoMap().find(name);
208 ss <<
"+ " << name <<
" not found. Available names are " << endl;
209 ss << mapToString<string, Cinfo*>(
cinfoMap() );
210 dump(ss.str(),
"DEBUG");
226 map< string, Finfo*>::const_iterator i =
finfoMap_.find( name );
241 if ( fid <
funcs_.size () )
282 if ( ancestor ==
"Neutral" )
return 1;
283 const Cinfo* base =
this;
285 if ( ancestor == base->
name_ )
294 for ( map< string, Finfo*>::const_iterator i =
finfoMap_.begin();
299 cout << df->
getFid() <<
" " << df->
name() << endl;
309 static map<std::string, Cinfo*> lookup_;
340 "Name of base class",
344 static string doc[] =
347 "Author",
"Upi Bhalla",
348 "Description",
"Class information object."
351 static Finfo* cinfoFinfos[] = {
361 sizeof( cinfoFinfos ) /
sizeof (
Finfo* ),
364 sizeof(doc)/
sizeof(
string)
379 for (map <string, string>::const_iterator ii =
doc_.begin(); ii !=
doc_.end(); ++ii){
380 doc <<
'\n' << ii->first <<
":\t\t" << ii->second << endl;
388 "This Finfo is a dummy. If you are reading this you have used an invalid index",
554 static const string err =
"";
555 for ( vector< Finfo* >::const_iterator i =
srcFinfos_.begin();
565 cout <<
"Error: Cinfo::srcFinfoName( " << bid <<
" ): not found\n";
571 static const string err =
"";
572 for ( vector< Finfo* >::const_iterator i =
destFinfos_.begin();
576 if ( df->
getFid() == fid ) {
582 cout <<
"Error: Cinfo::destFinfoName( " << fid <<
" ): not found\n";
592 unsigned int num = 0;
593 for ( map< string, Cinfo* >::iterator
596 vector< const OpFunc* >& vec = i->second->funcs_;
597 for( vector< const OpFunc* >::iterator
598 j = vec.begin(); j != vec.end(); ++j )
vector< Finfo * > valueFinfos_
Keep track of all ValueFinfos.
static void makeCinfoElements(Id parent)
const Cinfo * baseCinfo() const
virtual void registerFinfo(Cinfo *c)=0
Id init(int argc, char **argv, bool &doUnitTests, bool &doRegressionTests, unsigned int &benchmark)
Finfo * getFieldElementFinfo(unsigned int i) const
FuncId registerOpFunc(const OpFunc *f)
const OpFunc * getOpFunc(FuncId fid) const
Finfo * getDestFinfo(unsigned int i) const
Finfo * getValueFinfo(unsigned int i) const
unsigned int getNumSrcFinfo() const
void init(Finfo **finfoArray, unsigned int nFinfos)
BindIndex registerBindIndex()
unsigned int getNumDestFinfo() const
BindIndex getBindIndex() const
vector< Finfo * > destFinfos_
Keep track of all DestFinfos.
static unsigned int numCoreOpFunc_
static DestFinfo dummy("dummy","This Finfo is a dummy. If you are reading this you have used an invalid index", 0)
bool setIndex(unsigned int i)
Used when rebuilding the Fid->OpFunc mapping.
map< string, Finfo * > finfoMap_
unsigned int getNumValueFinfo() const
static const Cinfo * initCinfo()
static const Cinfo * find(const std::string &name)
void buildFinfoElement(Id parent, vector< Finfo * > &f, const string &name)
static map< string, Cinfo * > & cinfoMap()
const map< string, Finfo * > & finfoMap() const
const string & name() const
const DinfoBase * dinfo() const
vector< Finfo * > fieldElementFinfos_
Keep track of all FieldElementFinfos.
const std::string & name() const
vector< Finfo * > sharedFinfos_
Keep track of all SharedFinfos.
static const Cinfo * initCinfo()
void overrideFunc(FuncId fid, const OpFunc *f)
void registerFinfo(Finfo *f)
void postCreationFunc(Id newId, Element *newElm) const
Finfo * getLookupFinfo(unsigned int i) const
unsigned int getNumFieldElementFinfo() const
bool isA(const string &ancestor) const
unsigned int getNumSharedFinfo() const
const string & destFinfoName(FuncId fid) const
Finfo * getSrcFinfo(unsigned int i) const
vector< Finfo * > lookupFinfos_
Keep track of all LookupFinfos.
virtual void assignData(char *copy, unsigned int copyEntries, const char *orig, unsigned int origEntries) const =0
string getBaseClass() const
vector< const Finfo * > postCreationFinfos_
Finfo * getSharedFinfo(unsigned int i)
void setNumFinfo(unsigned int v)
std::map< std::string, std::string > doc_
static const Cinfo * cinfoCinfo
vector< const OpFunc * > funcs_
virtual char * data(unsigned int rawIndex, unsigned int fieldIndex=0) const =0
static void rebuildOpIndex()
static bool adopt(ObjId parent, Id child, unsigned int msgIndex)
static unsigned int rebuildOpIndex()
cleans out the entire Ops vector. Returns size of orig vector.
unsigned int numBindIndex() const
const string & srcFinfoName(BindIndex bid) const
vector< Finfo * > srcFinfos_
Keep track of all SrcFinfos.
void registerPostCreationFinfo(const Finfo *f)
static const Cinfo * initCinfo()
unsigned int getNumLookupFinfo() const
const Finfo * findFinfo(const string &name) const