2010-01-19 03:50:19 -06:00
|
|
|
/*
|
|
|
|
* Name.h
|
|
|
|
* openChams
|
|
|
|
*
|
|
|
|
* Created by damien dupuis on 18/12/09.
|
|
|
|
* Copyright 2009 UPMC / LIP6. All rights reserved.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __OPENCHAMS_NAME_H__
|
|
|
|
#define __OPENCHAMS_NAME_H__
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <map>
|
2010-01-29 03:10:44 -06:00
|
|
|
|
|
|
|
#include "OpenChamsException.h"
|
2010-01-19 03:50:19 -06:00
|
|
|
|
|
|
|
namespace OpenChams {
|
|
|
|
class Name {
|
|
|
|
public:
|
2010-01-29 03:10:44 -06:00
|
|
|
Name(std::string);
|
|
|
|
Name(const char*);
|
2010-01-19 03:50:19 -06:00
|
|
|
|
2010-01-29 03:10:44 -06:00
|
|
|
bool operator==(const Name&);
|
|
|
|
bool operator==(const std::string&);
|
|
|
|
bool operator<(const Name) const;
|
2010-01-19 03:50:19 -06:00
|
|
|
|
2010-01-29 03:10:44 -06:00
|
|
|
inline const std::string& getString() const;
|
2010-01-19 03:50:19 -06:00
|
|
|
|
|
|
|
private:
|
2010-01-29 03:10:44 -06:00
|
|
|
unsigned long _id;
|
|
|
|
const std::string *_str;
|
2010-01-19 03:50:19 -06:00
|
|
|
|
2010-01-29 03:10:44 -06:00
|
|
|
static std::map<std::string, unsigned long> _dict;
|
|
|
|
static unsigned long _globalId;
|
2010-01-19 03:50:19 -06:00
|
|
|
};
|
|
|
|
|
2010-01-29 03:10:44 -06:00
|
|
|
inline const std::string& Name::getString() const{
|
|
|
|
if (!_str) {
|
|
|
|
throw OpenChamsException("[ERROR] Name object has no string");
|
|
|
|
}
|
2010-01-19 03:50:19 -06:00
|
|
|
return *_str;
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace
|
2010-01-26 09:05:20 -06:00
|
|
|
#endif
|
|
|
|
|