Prevent mounted players to use aqua_speed. Aqua speed at +33%
[ryzomcore.git] / nel / tools / 3d / pipeline_max / storage_value.h
blobcce8c4bce3ffb00ad848547584c9b7f8b47597e5
1 /**
2 * \file storage_value.h
3 * \brief CStorageValue
4 * \date 2012-08-18 15:00GMT
5 * \author Jan Boon (Kaetemi)
6 * CStorageValue
7 */
9 /*
10 * Copyright (C) 2012 by authors
12 * This file is part of RYZOM CORE PIPELINE.
13 * RYZOM CORE PIPELINE is free software: you can redistribute it
14 * and/or modify it under the terms of the GNU Affero General Public
15 * License as published by the Free Software Foundation, either
16 * version 3 of the License, or (at your option) any later version.
18 * RYZOM CORE PIPELINE is distributed in the hope that it will be
19 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
20 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Affero General Public License for more details.
23 * You should have received a copy of the GNU Affero General Public
24 * License along with RYZOM CORE PIPELINE. If not, see
25 * <http://www.gnu.org/licenses/>.
28 #ifndef PIPELINE_STORAGE_VALUE_H
29 #define PIPELINE_STORAGE_VALUE_H
30 #include <nel/misc/types_nl.h>
32 // STL includes
34 // NeL includes
35 #include <nel/misc/ucstring.h>
36 #include <nel/misc/string_common.h>
38 // Project includes
39 #include "storage_object.h"
41 namespace PIPELINE {
42 namespace MAX {
44 template<typename T>
45 class CStorageValue : public IStorageObject
47 public:
48 // public data
49 typedef T TType;
50 TType Value;
52 // inherited
53 virtual std::string className() const;
54 virtual void serial(NLMISC::IStream &stream);
55 virtual void toString(std::ostream &ostream, const std::string &pad = "") const;
57 public: // should be protected but that doesn't compile, nice c++!
58 // Sets size when reading
59 virtual void setSize(sint32 size);
60 // Gets the size when writing, return false if unknown
61 virtual bool getSize(sint32 &size) const;
64 template <typename T>
65 std::string CStorageValue<T>::className() const
67 return "CStorageValue";
70 template <typename T>
71 void CStorageValue<T>::serial(NLMISC::IStream &stream)
73 stream.serial(Value);
76 template <>
77 void CStorageValue<std::string>::serial(NLMISC::IStream &stream);
79 template <>
80 void CStorageValue<ucstring>::serial(NLMISC::IStream &stream);
82 template <typename T>
83 void CStorageValue<T>::toString(std::ostream &ostream, const std::string &pad) const
85 std::string s = NLMISC::toString(Value);
86 ostream << "(" << className() << ") { " << s << " } ";
89 template <>
90 void CStorageValue<ucstring>::toString(std::ostream &ostream, const std::string &pad) const;
92 template <typename T>
93 void CStorageValue<T>::setSize(sint32 size)
95 if (size != sizeof(Value))
96 nlerror("Size does not match value type");
97 IStorageObject::setSize(size);
100 template <>
101 void CStorageValue<std::string>::setSize(sint32 size);
103 template <>
104 void CStorageValue<ucstring>::setSize(sint32 size);
106 template <typename T>
107 bool CStorageValue<T>::getSize(sint32 &size) const
109 size = sizeof(Value);
110 return true;
113 template <>
114 bool CStorageValue<std::string>::getSize(sint32 &size) const;
116 template <>
117 bool CStorageValue<ucstring>::getSize(sint32 &size) const;
119 } /* namespace MAX */
120 } /* namespace PIPELINE */
122 #endif /* #ifndef PIPELINE_STORAGE_VALUE_H */
124 /* end of file */