Changeset 314 for trunk/src


Ignore:
Timestamp:
Mar 10, 2006 8:26:54 AM (18 years ago)
Author:
cxsong
Message:

added key cmp func map in serializer

Location:
trunk/src/mesh
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/mesh/serializer.cc

    r313 r314  
    99{
    1010        const char* key = obj->objectName();
     11
    1112        // add object pointer to object map
    1213        m_objMap[key] = obj;
     
    105106RpSerializer::getObject(const char* objectName)
    106107{
     108#ifdef DEBUG
     109                printf("RpSerializer::getObject: %s, len=%d\n", objectName,strlen(objectName));
     110#endif
    107111        typeObjMap::iterator iter = m_objMap.find(objectName);
    108112       
     
    271275        typeObjMap::iterator iter;
    272276        for (iter = m_objMap.begin(); iter != m_objMap.end(); iter++)
    273                 printf("objMap: %s \t %x\n", (*iter).first, (unsigned)(*iter).second);
     277                printf("objMap: %s= ptr=%x\n", (*iter).first, (unsigned)(*iter).second);
    274278
    275279        typeRefCount::iterator it;
    276280        for (it = m_refCount.begin(); it != m_refCount.end(); it++)
    277                 printf("count: %s \t %d\n", (*it).first, (*it).second);
     281                printf("count: %s= count=%d\n", (*it).first, (*it).second);
    278282};
    279283
     
    292296
    293297        if (header == RpGrid1d_current_version) {
    294                 obj = new RpGrid1d; // create new object
     298                obj = new RpGrid1d(); // create new object
    295299                obj->deserialize(buf);
    296300                return obj;
  • trunk/src/mesh/serializer.h

    r308 r314  
    6262        RpSerializable* createObject(std::string header, const char* buf);
    6363
     64        struct rpStrCmp {
     65                bool operator()( const char* s1, const char* s2 ) const {
     66                        return strcmp( s1, s2 ) < 0;
     67                }
     68        };
     69
    6470private:
    65         typedef map<const char*, RpSerializable*> typeObjMap;
    66         typedef map<const char*, int> typeRefCount;
     71        typedef map<const char*, RpSerializable*, rpStrCmp> typeObjMap;
     72        typedef map<const char*, int, rpStrCmp> typeRefCount;
    6773
    6874        // archive of objects referenced by their names (e.g., output.field)
Note: See TracChangeset for help on using the changeset viewer.