Files
unison/src/core/enum.h

82 lines
1.9 KiB
C
Raw Normal View History

2008-02-04 23:13:54 +01:00
#ifndef ENUM_VALUE_H
#define ENUM_VALUE_H
2008-02-20 21:45:42 +01:00
#include "attribute.h"
#include "attribute-accessor-helper.h"
2008-02-04 23:13:54 +01:00
#include <list>
namespace ns3 {
2008-02-21 00:00:18 +01:00
class Enum : public AttributeValue
2008-02-04 23:13:54 +01:00
{
public:
2008-02-21 00:00:18 +01:00
Enum (int v);
2008-02-04 23:13:54 +01:00
void Set (int v);
int Get (void) const;
2008-02-20 19:57:31 +01:00
virtual Attribute Copy (void) const;
2008-02-18 00:18:45 +01:00
virtual std::string SerializeToString (Ptr<const AttributeChecker> checker) const;
virtual bool DeserializeFromString (std::string value, Ptr<const AttributeChecker> checker);
2008-02-04 23:13:54 +01:00
2008-02-21 00:00:18 +01:00
Enum (Attribute value);
2008-02-20 19:57:31 +01:00
operator Attribute () const;
2008-02-04 23:13:54 +01:00
private:
int m_v;
};
2008-02-18 00:18:45 +01:00
class EnumChecker : public AttributeChecker
2008-02-04 23:13:54 +01:00
{
public:
2008-02-18 00:18:45 +01:00
EnumChecker ();
2008-02-04 23:13:54 +01:00
void AddDefault (int v, std::string name);
void Add (int v, std::string name);
2008-02-20 19:57:31 +01:00
virtual bool Check (Attribute value) const;
2008-02-04 23:13:54 +01:00
private:
2008-02-21 00:00:18 +01:00
friend class Enum;
2008-02-04 23:13:54 +01:00
typedef std::list<std::pair<int,std::string> > ValueSet;
ValueSet m_valueSet;
};
2008-02-18 00:18:45 +01:00
template <typename T1>
2008-02-20 20:57:59 +01:00
Ptr<const AttributeAccessor> MakeEnumAccessor (T1 a1);
2008-02-18 00:18:45 +01:00
template <typename T1, typename T2>
2008-02-20 20:57:59 +01:00
Ptr<const AttributeAccessor> MakeEnumAccessor (T1 a1, T2 a2);
Ptr<const AttributeChecker> MakeEnumChecker (int v1, std::string n1,
int v2 = 0, std::string n2 = "",
int v3 = 0, std::string n3 = "",
int v4 = 0, std::string n4 = "",
int v5 = 0, std::string n5 = "",
int v6 = 0, std::string n6 = "",
int v7 = 0, std::string n7 = "",
int v8 = 0, std::string n8 = "",
int v9 = 0, std::string n9 = "",
int v10 = 0, std::string n10 = "",
int v11 = 0, std::string n11 = "",
int v12 = 0, std::string n12 = "");
2008-02-04 23:13:54 +01:00
} // namespace ns3
namespace ns3 {
2008-02-18 00:18:45 +01:00
template <typename T1>
2008-02-20 20:57:59 +01:00
Ptr<const AttributeAccessor> MakeEnumAccessor (T1 a1)
2008-02-18 00:18:45 +01:00
{
return MakeAccessorHelper<Enum> (a1);
2008-02-18 00:18:45 +01:00
}
template <typename T1, typename T2>
2008-02-20 20:57:59 +01:00
Ptr<const AttributeAccessor> MakeEnumAccessor (T1 a1, T2 a2)
2008-02-04 23:13:54 +01:00
{
return MakeAccessorHelper<Enum> (a1, a2);
2008-02-04 23:13:54 +01:00
}
} // namespace ns3
#endif /* ENUM_VALUE_H */