00001
00002
00003 #ifndef COMPOSITE_TYPE_H
00004 #define COMPOSITE_TYPE_H
00005
00006 #include "Object.h"
00007 #include <map>
00008
00009 namespace FD {
00010
00012 class CompositeType : public Object {
00013 public:
00014 typedef std::map<std::string, ObjectRef> map_type;
00015 typedef std::pair<std::string, ObjectRef> map_element_type;
00016 CompositeType() {}
00017 void printOn(std::ostream &out) const;
00018 void readFrom(std::istream &in);
00019 void addField(const std::string &name, ObjectRef obj) {fields[name]=obj;}
00020 void conservativeAddField(const std::string &name, ObjectRef obj);
00021 ObjectRef get(const std::string &name) const
00022 {
00023 map_type::const_iterator it = fields.find(name);
00024 if (it==fields.end())
00025 throw new GeneralException(std::string("Unknown field: ") + name, __FILE__, __LINE__);
00026 return it->second;
00027 }
00028
00029 map_type getAllFields()
00030 {
00031 return fields;
00032 }
00033
00034 private:
00035 map_type fields;
00036 };
00037
00038 }
00039 #endif