#define TYPE(t)
#define TYPEWITHSTRAYDATA(t)
+#define TYPE_NONDETERMINISTIC(t)
#define TYPE_FEATUREFUL(t)
#define TYPE_FEATUREFUL_STRAYDATA(t)
+#define TYPE_FEATUREFUL_NONDETERMINISTIC(t)
#define TYPE_NOCOPY(t)
#define MESSAGE(t)
#include "types.h"
#undef TYPE
#undef TYPEWITHSTRAYDATA
+#undef TYPE_NONDETERMINISTIC
#undef TYPE_FEATUREFUL
#undef TYPE_FEATUREFUL_STRAYDATA
+#undef TYPE_FEATUREFUL_NONDETERMINISTIC
#undef TYPE_NOCOPY
#undef MESSAGE
virtual void generate() = 0;
virtual int num_generated() = 0;
virtual string select_generated(unsigned n) = 0;
+ virtual bool is_deterministic() = 0;
//virtual void print(ostream& out) = 0;
};
T* m_object;
list<T*> m_list;
bool stray_okay;
+ bool nondeterministic;
public:
- DencoderBase(bool stray_okay) : m_object(new T), stray_okay(stray_okay) {}
+ DencoderBase(bool stray_okay, bool nondeterministic)
+ : m_object(new T),
+ stray_okay(stray_okay),
+ nondeterministic(nondeterministic) {}
~DencoderBase() {
delete m_object;
}
m_object = *p;
return string();
}
+
+ bool is_deterministic() {
+ return !nondeterministic;
+ }
};
template<class T>
class DencoderImplNoFeatureNoCopy : public DencoderBase<T> {
public:
- DencoderImplNoFeatureNoCopy(bool stray_ok)
- : DencoderBase<T>(stray_ok) {}
+ DencoderImplNoFeatureNoCopy(bool stray_ok, bool nondeterministic)
+ : DencoderBase<T>(stray_ok, nondeterministic) {}
virtual void encode(bufferlist& out, uint64_t features) {
out.clear();
this->m_object->encode(out);
template<class T>
class DencoderImplNoFeature : public DencoderImplNoFeatureNoCopy<T> {
public:
- DencoderImplNoFeature(bool stray_ok)
- : DencoderImplNoFeatureNoCopy<T>(stray_ok) {}
+ DencoderImplNoFeature(bool stray_ok, bool nondeterministic)
+ : DencoderImplNoFeatureNoCopy<T>(stray_ok, nondeterministic) {}
void copy() {
T *n = new T;
*n = *this->m_object;
template<class T>
class DencoderImplFeatureful : public DencoderBase<T> {
public:
- DencoderImplFeatureful(bool stray_ok) : DencoderBase<T>(stray_ok) {}
+ DencoderImplFeatureful(bool stray_ok, bool nondeterministic)
+ : DencoderBase<T>(stray_ok, nondeterministic) {}
virtual void encode(bufferlist& out, uint64_t features) {
out.clear();
::encode(*(this->m_object), out, features);
m_object = *p;
return string();
}
+ bool is_deterministic() {
+ return true;
+ }
//void print(ostream& out) {
//out << m_object << std::endl;
#define T_STR(x) #x
#define T_STRINGIFY(x) T_STR(x)
-#define TYPE(t) dencoders[T_STRINGIFY(t)] = new DencoderImplNoFeature<t>(false);
-#define TYPEWITHSTRAYDATA(t) dencoders[T_STRINGIFY(t)] = new DencoderImplNoFeature<t>(true);
-#define TYPE_FEATUREFUL(t) dencoders[T_STRINGIFY(t)] = new DencoderImplFeatureful<t>(false);
-#define TYPE_FEATUREFUL_STRAYDATA(t) dencoders[T_STRINGIFY(t)] = new DencoderImplFeatureful<t>(true);
-#define TYPE_NOCOPY(t) dencoders[T_STRINGIFY(t)] = new DencoderImplNoFeatureNoCopy<t>(false);
+#define TYPE(t) dencoders[T_STRINGIFY(t)] = new DencoderImplNoFeature<t>(false, false);
+#define TYPEWITHSTRAYDATA(t) dencoders[T_STRINGIFY(t)] = new DencoderImplNoFeature<t>(true, false);
+#define TYPE_NONDETERMINISTIC(t) dencoders[T_STRINGIFY(t)] = new DencoderImplNoFeature<t>(false, true);
+#define TYPE_FEATUREFUL(t) dencoders[T_STRINGIFY(t)] = new DencoderImplFeatureful<t>(false, false);
+#define TYPE_FEATUREFUL_STRAYDATA(t) dencoders[T_STRINGIFY(t)] = new DencoderImplFeatureful<t>(true, false);
+#define TYPE_FEATUREFUL_NONDETERMINISTIC(t) dencoders[T_STRINGIFY(t)] = new DencoderImplFeatureful<t>(false, true);
+#define TYPE_NOCOPY(t) dencoders[T_STRINGIFY(t)] = new DencoderImplNoFeatureNoCopy<t>(false, false);
#define MESSAGE(t) dencoders[T_STRINGIFY(t)] = new MessageDencoderImpl<t>;
#include "types.h"
#undef TYPE
#undef TYPEWITHSTRAYDATA
+#undef TYPE_NONDETERMINISTIC
#undef TYPE_FEATUREFUL
#undef TYPE_FEATUREFUL_STRAYDATA
+#undef TYPE_FEATUREFUL_NONDETERMINISTIC
#undef T_STR
#undef T_STRINGIFY