Changeset 790 for cpp/frams/neuro/neurofactory.cpp
- Timestamp:
- 05/29/18 15:46:35 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
cpp/frams/neuro/neurofactory.cpp
r375 r790 13 13 NeuroImpl* NeuroFactory::getImplementation(NeuroClass *nc) 14 14 { 15 if (nc!=NULL)15 if (nc != NULL) 16 16 { 17 std::map<NeuroClass*,NeuroImpl*>::iterator it=impl.find(nc);18 if (it!=impl.end())19 return it->second;17 std::map<NeuroClass*, NeuroImpl*>::iterator it = impl.find(nc); 18 if (it != impl.end()) 19 return it->second; 20 20 } 21 return NULL;21 return NULL; 22 22 } 23 23 24 24 NeuroImpl* NeuroFactory::createNeuroImpl(NeuroClass *nc) 25 25 { 26 if (!nc) return 0;27 if (!nc->active) return 0;28 NeuroImpl* ni=getImplementation(nc);29 if (!ni) return 0;30 ni=ni->makeNew();31 if (ni) ni->neuroclass=nc;32 return ni;26 if (!nc) return 0; 27 if (!nc->active) return 0; 28 NeuroImpl* ni = getImplementation(nc); 29 if (!ni) return 0; 30 ni = ni->makeNew(); 31 if (ni) ni->neuroclass = nc; 32 return ni; 33 33 } 34 34 35 NeuroImpl* NeuroFactory::setImplementation(const SString& classname, NeuroImpl *ni,bool deleteold)35 NeuroImpl* NeuroFactory::setImplementation(const SString& classname, NeuroImpl *ni, bool deleteold) 36 36 { 37 NeuroClass *nc=Neuro::getClass(classname);38 if (!nc) return ni;39 return setImplementation(nc,ni,deleteold);37 NeuroClass *nc = Neuro::getClass(classname); 38 if (!nc) return ni; 39 return setImplementation(nc, ni, deleteold); 40 40 } 41 41 42 NeuroImpl* NeuroFactory::setImplementation(NeuroClass *nc, NeuroImpl *ni,bool deleteold)42 NeuroImpl* NeuroFactory::setImplementation(NeuroClass *nc, NeuroImpl *ni, bool deleteold) 43 43 { 44 if (nc==NULL) return NULL;45 std::map<NeuroClass*,NeuroImpl*>::iterator it=impl.find(nc);46 NeuroImpl* old_ni=NULL;47 if (it==impl.end())44 if (nc == NULL) return NULL; 45 std::map<NeuroClass*, NeuroImpl*>::iterator it = impl.find(nc); 46 NeuroImpl* old_ni = NULL; 47 if (it == impl.end()) 48 48 { 49 if (ni!=NULL)49 if (ni != NULL) 50 50 { 51 impl[nc]=ni;52 nc->impl_count++;51 impl[nc] = ni; 52 nc->impl_count++; 53 53 } 54 return NULL;54 return NULL; 55 55 } 56 else56 else 57 57 { 58 old_ni=it->second;59 if (ni)60 it->second=ni;61 else58 old_ni = it->second; 59 if (ni) 60 it->second = ni; 61 else 62 62 { 63 impl.erase(it);64 nc->impl_count--;63 impl.erase(it); 64 nc->impl_count--; 65 65 } 66 66 } 67 if (deleteold && old_ni) delete old_ni;68 return old_ni;67 if (deleteold && old_ni) delete old_ni; 68 return old_ni; 69 69 } 70 70 … … 73 73 void NeuroFactory::setStandardImplementation() 74 74 { 75 SETIMPLEMENTATION75 SETIMPLEMENTATION 76 76 } 77 77 78 78 void NeuroFactory::freeImplementation() 79 79 { 80 for(int i=0;i<Neuro::getClassCount();i++)81 setImplementation(Neuro::getClass(i),0);80 for (int i = 0; i < Neuro::getClassCount(); i++) 81 setImplementation(Neuro::getClass(i), 0); 82 82 } 83 83 84 84 void NeuroFactory::removeUnimplemented() 85 85 { 86 SString removed;87 for(int i=0;i<Neuro::getClassCount();i++)86 SString removed; 87 for (int i = 0; i < Neuro::getClassCount(); i++) 88 88 { 89 NeuroClass *nc=Neuro::getClass(i);90 if (nc->impl_count==0)89 NeuroClass *nc = Neuro::getClass(i); 90 if (nc->impl_count == 0) 91 91 { 92 removed+=nc->getName();93 removed+=" ";94 NeuroLibrary::staticlibrary.classes-=i;95 i--;96 delete nc;92 removed += nc->getName(); 93 removed += " "; 94 NeuroLibrary::staticlibrary.classes -= i; 95 i--; 96 delete nc; 97 97 } 98 98 } 99 if (removed.len())100 logPrintf("NeuroFactory","removeUninmplemented",LOG_INFO,101 "Removed Neuro classes: %s",removed.c_str());99 if (removed.len()) 100 logPrintf("NeuroFactory", "removeUninmplemented", LOG_INFO, 101 "Removed Neuro classes: %s", removed.c_str()); 102 102 } 103
Note: See TracChangeset
for help on using the changeset viewer.