These classes are extremely likely to require references to other
objects, and requiring a collection makes the code more straightforward.
20 files changed:
-Font::Loader::Loader(Font &f, Collection *c):
- DataFile::CollectionObjectLoader<Font>(f, c)
+Font::Loader::Loader(Font &f, Collection &c):
+ DataFile::CollectionObjectLoader<Font>(f, &c)
{
add("native_size", &Font::native_size);
add("ascent", &Font::ascent);
{
add("native_size", &Font::native_size);
add("ascent", &Font::ascent);
class Loader: public DataFile::CollectionObjectLoader<Font>
{
public:
class Loader: public DataFile::CollectionObjectLoader<Font>
{
public:
- Loader(Font &f): Loader(f, 0) { }
- Loader(Font &f, Collection &c): Loader(f, &c) { }
- private:
- Loader(Font &, Collection *);
+ Loader(Font &, Collection &);
void glyph(unsigned);
void kerning(unsigned, unsigned, float);
void ligature(unsigned, unsigned, unsigned);
void glyph(unsigned);
void kerning(unsigned, unsigned, float);
void ligature(unsigned, unsigned, unsigned);
Step stp;
stp.tag = tag;
stp.slot_name = rend;
Step stp;
stp.tag = tag;
stp.slot_name = rend;
- if(coll)
- {
- Step::Loader ldr(stp, *coll);
- ldr.set_inline_base_name(format("%s/%d.step", get_source(), obj.steps.size()));
- load_sub_with(ldr);
- }
- else
- load_sub(stp);
+ Step::Loader ldr(stp, *coll);
+ ldr.set_inline_base_name(format("%s/%d.step", get_source(), obj.steps.size()));
+ load_sub_with(ldr);
obj.steps.push_back(stp);
}
obj.steps.push_back(stp);
}
-SequenceTemplate::Step::Loader::Loader(Step &p, Collection *c):
- DataFile::CollectionObjectLoader<Step>(p, c)
+SequenceTemplate::Step::Loader::Loader(Step &p, Collection &c):
+ DataFile::CollectionObjectLoader<Step>(p, &c)
{
add("blend", &Loader::blend);
add("blend", &Loader::blend_factors);
{
add("blend", &Loader::blend);
add("blend", &Loader::blend_factors);
void SequenceTemplate::Step::Loader::lighting_inline()
{
RefPtr<Lighting> lightn = new Lighting;
void SequenceTemplate::Step::Loader::lighting_inline()
{
RefPtr<Lighting> lightn = new Lighting;
+ load_sub(*lightn, get_collection());
get_collection().add(inline_base_name+".lightn", lightn.get());
obj.lighting = lightn.release();
}
get_collection().add(inline_base_name+".lightn", lightn.get());
obj.lighting = lightn.release();
}
std::string inline_base_name;
public:
std::string inline_base_name;
public:
- Loader(Step &s): Loader(s, 0) { }
- Loader(Step &s, Collection &c): Loader(s, &c) { }
- private:
- Loader(Step &, Collection *);
- void init();
+ Loader(Step &, Collection &);
void set_inline_base_name(const std::string &);
private:
void set_inline_base_name(const std::string &);
private:
DataFile::Loader::ActionMap BasicMaterial::Loader::shared_actions;
DataFile::Loader::ActionMap BasicMaterial::Loader::shared_actions;
-BasicMaterial::Loader::Loader(BasicMaterial &m):
- DerivedObjectLoader<BasicMaterial, Material::PropertyLoader<BasicMaterial> >(m)
-{
- set_actions(shared_actions);
-}
-
BasicMaterial::Loader::Loader(BasicMaterial &m, Collection &c):
DerivedObjectLoader<BasicMaterial, Material::PropertyLoader<BasicMaterial> >(m, c)
{
BasicMaterial::Loader::Loader(BasicMaterial &m, Collection &c):
DerivedObjectLoader<BasicMaterial, Material::PropertyLoader<BasicMaterial> >(m, c)
{
static ActionMap shared_actions;
public:
static ActionMap shared_actions;
public:
- Loader(BasicMaterial &);
Loader(BasicMaterial &, Collection &);
private:
Loader(BasicMaterial &, Collection &);
private:
DataFile::Loader::ActionMap Lighting::Loader::shared_actions;
DataFile::Loader::ActionMap Lighting::Loader::shared_actions;
-Lighting::Loader::Loader(Lighting &l):
- CollectionObjectLoader<Lighting>(l, 0)
-{
- set_actions(shared_actions);
-}
-
Lighting::Loader::Loader(Lighting &l, Collection &c):
CollectionObjectLoader<Lighting>(l, &c)
{
Lighting::Loader::Loader(Lighting &l, Collection &c):
CollectionObjectLoader<Lighting>(l, &c)
{
static ActionMap shared_actions;
public:
static ActionMap shared_actions;
public:
Loader(Lighting &, Collection &);
private:
Loader(Lighting &, Collection &);
private:
-Material::Loader::Loader(Material &m):
- CollectionObjectLoader(m, 0)
-{ }
-
Material::Loader::Loader(Material &m, Collection &c):
CollectionObjectLoader(m, &c)
{ }
Material::Loader::Loader(Material &m, Collection &c):
CollectionObjectLoader(m, &c)
{ }
DataFile::Loader::ActionMap Material::GenericLoader::shared_actions;
DataFile::Loader::ActionMap Material::GenericLoader::shared_actions;
-Material::GenericLoader::GenericLoader():
- coll(0),
+Material::GenericLoader::GenericLoader(DataFile::Collection &c):
+ coll(c),
material(0),
mat_loader(0)
{
set_actions(shared_actions);
}
material(0),
mat_loader(0)
{
set_actions(shared_actions);
}
-Material::GenericLoader::GenericLoader(DataFile::Collection &c):
- GenericLoader()
-{
- coll = &c;
-}
-
Material::GenericLoader::~GenericLoader()
{
delete material;
Material::GenericLoader::~GenericLoader()
{
delete material;
class Loader: public DataFile::CollectionObjectLoader<Material>
{
protected:
class Loader: public DataFile::CollectionObjectLoader<Material>
{
protected:
Loader(Material &, Collection &);
virtual void init_actions();
Loader(Material &, Collection &);
virtual void init_actions();
class PropertyLoader: public DataFile::DerivedObjectLoader<Material, Loader>
{
protected:
class PropertyLoader: public DataFile::DerivedObjectLoader<Material, Loader>
{
protected:
- PropertyLoader(C &m): DerivedObjectLoader<Material, Loader>(m) { }
PropertyLoader(C &m, Collection &c): DerivedObjectLoader<Material, Loader>(m, c) { }
void add_property(const std::string &, void (C::*)(float), void (C::*)(const Texture *));
PropertyLoader(C &m, Collection &c): DerivedObjectLoader<Material, Loader>(m, c) { }
void add_property(const std::string &, void (C::*)(float), void (C::*)(const Texture *));
void operator()(const std::string &, GenericLoader &) const;
};
void operator()(const std::string &, GenericLoader &) const;
};
- DataFile::Collection *coll;
+ DataFile::Collection &coll;
Material *material;
Loader *mat_loader;
static ActionMap shared_actions;
public:
Material *material;
Loader *mat_loader;
static ActionMap shared_actions;
public:
GenericLoader(DataFile::Collection &);
~GenericLoader();
GenericLoader(DataFile::Collection &);
~GenericLoader();
T *mat = new T;
ldr.material = mat;
T *mat = new T;
ldr.material = mat;
- if(ldr.coll)
- ldr.mat_loader = new typename T::Loader(*mat, *ldr.coll);
- else
- ldr.mat_loader = new typename T::Loader(*mat);
+ ldr.mat_loader = new typename T::Loader(*mat, ldr.coll);
ldr.add_auxiliary_loader(*ldr.mat_loader);
}
ldr.add_auxiliary_loader(*ldr.mat_loader);
}
DataFile::Loader::ActionMap PbrMaterial::Loader::shared_actions;
DataFile::Loader::ActionMap PbrMaterial::Loader::shared_actions;
-PbrMaterial::Loader::Loader(PbrMaterial &m):
- DerivedObjectLoader<PbrMaterial, Material::PropertyLoader<PbrMaterial> >(m)
-{
- set_actions(shared_actions);
-}
-
PbrMaterial::Loader::Loader(PbrMaterial &m, Collection &c):
DerivedObjectLoader<PbrMaterial, Material::PropertyLoader<PbrMaterial> >(m, c)
{
PbrMaterial::Loader::Loader(PbrMaterial &m, Collection &c):
DerivedObjectLoader<PbrMaterial, Material::PropertyLoader<PbrMaterial> >(m, c)
{
static ActionMap shared_actions;
public:
static ActionMap shared_actions;
public:
Loader(PbrMaterial &, Collection &);
private:
Loader(PbrMaterial &, Collection &);
private:
DataFile::Loader::ActionMap RenderMethod::Loader::shared_actions;
DataFile::Loader::ActionMap RenderMethod::Loader::shared_actions;
-RenderMethod::Loader::Loader(RenderMethod &p):
- DataFile::CollectionObjectLoader<RenderMethod>(p, 0)
-{
- set_actions(shared_actions);
-}
-
RenderMethod::Loader::Loader(RenderMethod &p, Collection &c):
DataFile::CollectionObjectLoader<RenderMethod>(p, &c)
{
RenderMethod::Loader::Loader(RenderMethod &p, Collection &c):
DataFile::CollectionObjectLoader<RenderMethod>(p, &c)
{
static ActionMap shared_actions;
public:
static ActionMap shared_actions;
public:
- Loader(RenderMethod &);
Loader(RenderMethod &, Collection &);
private:
virtual void init_actions();
Loader(RenderMethod &, Collection &);
private:
virtual void init_actions();
DataFile::Loader::ActionMap Technique::Loader::shared_actions;
DataFile::Loader::ActionMap Technique::Loader::shared_actions;
-Technique::Loader::Loader(Technique &t):
- DataFile::CollectionObjectLoader<Technique>(t, 0)
-{
- set_actions(shared_actions);
-}
-
Technique::Loader::Loader(Technique &t, Collection &c):
DataFile::CollectionObjectLoader<Technique>(t, &c)
{
Technique::Loader::Loader(Technique &t, Collection &c):
DataFile::CollectionObjectLoader<Technique>(t, &c)
{
void Technique::Loader::method(const string &n)
{
RenderMethod p;
void Technique::Loader::method(const string &n)
{
RenderMethod p;
- if(coll)
- {
- RenderMethod::Loader ldr(p, get_collection());
- ldr.set_inline_base_name(format("%s/%s.method", (inline_base_name.empty() ? FS::basename(get_source()) : inline_base_name), n));
- load_sub_with(ldr);
- }
- else
- load_sub(p);
+ RenderMethod::Loader ldr(p, get_collection());
+ ldr.set_inline_base_name(format("%s/%s.method", (inline_base_name.empty() ? FS::basename(get_source()) : inline_base_name), n));
+ load_sub_with(ldr);
if(!p.get_shader_program())
throw logic_error("no shader program in method");
if(!p.get_shader_program())
throw logic_error("no shader program in method");
static ActionMap shared_actions;
public:
static ActionMap shared_actions;
public:
Loader(Technique &, Collection &);
private:
virtual void init_actions();
Loader(Technique &, Collection &);
private:
virtual void init_actions();
DataFile::Loader::ActionMap UnlitMaterial::Loader::shared_actions;
DataFile::Loader::ActionMap UnlitMaterial::Loader::shared_actions;
-UnlitMaterial::Loader::Loader(UnlitMaterial &m):
- DerivedObjectLoader<UnlitMaterial, Material::PropertyLoader<UnlitMaterial> >(m)
-{
- set_actions(shared_actions);
-}
-
UnlitMaterial::Loader::Loader(UnlitMaterial &m, Collection &c):
DerivedObjectLoader<UnlitMaterial, Material::PropertyLoader<UnlitMaterial> >(m, c)
{
UnlitMaterial::Loader::Loader(UnlitMaterial &m, Collection &c):
DerivedObjectLoader<UnlitMaterial, Material::PropertyLoader<UnlitMaterial> >(m, c)
{
static ActionMap shared_actions;
public:
static ActionMap shared_actions;
public:
- Loader(UnlitMaterial &);
Loader(UnlitMaterial &, Collection &);
private:
Loader(UnlitMaterial &, Collection &);
private:
-Object::Loader::Loader(Object &o, Collection *c):
+Object::Loader::Loader(Object &o, Collection &c):
LodLoader(o, 0, c)
{
add("bounding_sphere_hint", &Loader::bounding_sphere_hint);
LodLoader(o, 0, c)
{
add("bounding_sphere_hint", &Loader::bounding_sphere_hint);
void Object::Loader::level_of_detail(unsigned i)
{
void Object::Loader::level_of_detail(unsigned i)
{
- LodLoader ldr(obj, i, coll);
+ LodLoader ldr(obj, i, get_collection());
-Object::LodLoader::LodLoader(Object &o, unsigned i, Collection *c):
- DataFile::CollectionObjectLoader<Object>(o, c),
+Object::LodLoader::LodLoader(Object &o, unsigned i, Collection &c):
+ DataFile::CollectionObjectLoader<Object>(o, &c),
index(i),
lod(obj.get_lod(index, "Object::LodLoader::LodLoader"))
{
index(i),
lod(obj.get_lod(index, "Object::LodLoader::LodLoader"))
{
LevelOfDetail &lod;
public:
LevelOfDetail &lod;
public:
- LodLoader(Object &, unsigned, Collection *);
+ LodLoader(Object &, unsigned, Collection &);
private:
void mesh(const std::string &);
private:
void mesh(const std::string &);
class Loader: public LodLoader
{
public:
class Loader: public LodLoader
{
public:
- Loader(Object &o): Loader(o, 0) { }
- Loader(Object &o, Collection &c): Loader(o, &c) { }
+ Loader(Object &, Collection &);
- Loader(Object &, Collection *);
virtual void finish();
void bounding_sphere_hint(float, float, float, float);
virtual void finish();
void bounding_sphere_hint(float, float, float, float);