00001 #ifndef __INSTANTIO_FIELD_H
00002 #define __INSTANTIO_FIELD_H
00003
00004 #ifdef _MSC_VER
00005 # pragma once
00006 #endif
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #include "InstantIODef.h"
00027 #include "BasicFieldAccessor.h"
00028 #include <string>
00029
00030
00031 namespace InstantIO
00032 {
00033
00034
00035 class Node;
00036
00037
00111 class INSTANTIO_DLLMAPPING Field
00112 {
00113 public:
00114
00129 inline Field(const std::string &name, const std::string &description, const std::string &defaultValue, const BasicFieldAccessor &fieldAccessor)
00130 : name_(name), description_(description), defaultValue_(defaultValue), fieldAccessor_(fieldAccessor.clone())
00131 {}
00132
00138 inline Field(const Field &other)
00139 : name_(other.name_), description_(other.description_), defaultValue_(other.defaultValue_), fieldAccessor_(other.fieldAccessor_->clone())
00140 {}
00141
00143 inline ~Field()
00144 { delete fieldAccessor_; }
00145
00151 inline const std::string &getName() const
00152 { return name_; }
00153
00162 inline const std::string &getDescription() const
00163 { return description_; }
00164
00171 inline const std::string &getDefaultValue() const
00172 { return defaultValue_; }
00173
00180 inline void set(Node &node, const std::string &value) const
00181 { fieldAccessor_->set(node, value); }
00182
00189 inline std::string get(const Node &node) const
00190 { return fieldAccessor_->get(node); }
00191
00199 inline bool sameValue(const Node &node, const std::string &value) const
00200 { return fieldAccessor_->sameValue(node, value); }
00201
00202 private:
00203
00205 const Field &operator=(const Field &);
00206
00208 std::string name_;
00209
00211 std::string description_;
00212
00214 std::string defaultValue_;
00215
00217 const BasicFieldAccessor *fieldAccessor_;
00218 };
00219
00220
00221 }
00222
00223
00224 #endif // __INSTANTIO_FIELD_H