AnnScriptFile.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <OgreResourceManager.h>
4 #include <OgreSharedPtr.h>
5 
6 #include "systemMacro.h"
7 #include <OgreSerializer.h>
8 
9 namespace Annwvyn
10 {
12  class AnnDllExport AnnScriptFile : public Ogre::Resource
13  {
16 
19 
20  protected:
22  void loadImpl() override;
23 
25  void unloadImpl() override;
26 
28  size_t calculateSize() const override;
29 
30  public:
32  AnnScriptFile(Ogre::ResourceManager* creator,
33  const Ogre::String& name,
34  Ogre::ResourceHandle handle,
35  const Ogre::String& group,
36  bool isManual = false,
37  Ogre::ManualResourceLoader* loader = nullptr);
39  virtual ~AnnScriptFile();
40 
42  const std::string& getSourceCode() const;
43 
45  void setLoadedSourceCode(const std::string& sourceCode);
46 
48  void signalLoadedInChaiscript();
49 
51  bool loadedInChaiscriptInterpretor() const;
52  };
53 
55  using AnnScriptFilePtr = Ogre::SharedPtr<AnnScriptFile>;
56 
58  class AnnDllExport AnnScriptFileSerializer : public Ogre::Serializer
59  {
60  public:
62  AnnScriptFileSerializer() = default;
63 
65  void exportChaiscript(const AnnScriptFile* pScriptSource,
66  const Ogre::String& filename);
67 
69  void importSourceCode(Ogre::DataStreamPtr& stream, AnnScriptFile* pDest);
70  };
71 
74  : public Ogre::ResourceManager,
75  public Ogre::Singleton<AnnScriptFileResourceManager>
76  {
77  protected:
79  Ogre::Resource* createImpl(
80  const Ogre::String& name,
81  Ogre::ResourceHandle handle,
82  const Ogre::String& group,
83  bool isManual,
84  Ogre::ManualResourceLoader* loader,
85  const Ogre::NameValuePairList* createParams) override;
86 
87  public:
90 
91  // ReSharper disable once CppHidingFunction
94 
96  virtual AnnScriptFilePtr load(const Ogre::String& name,
97  const Ogre::String& group);
98 
101 
104  };
105 } // namespace Annwvyn
file for defining macros used for symbol export regarding the way the OS does things.
Chaiscript File ResourceManager.
AnnScriptFileResourceManager()
construct and register an AnnScriptFileResourceManager
Ogre::SharedPtr< AnnScriptFile > AnnScriptFilePtr
Easy define of the shared pointer.
Namespace containing the totality of Annwvyn components.
Definition: AnnGetter.cpp:8
Chaiscript File Serializer.
bool loadedByChaiScript
Code evaluated on the chaiscript global scope.
Ogre::Resource * createImpl(const Ogre::String &name, Ogre::ResourceHandle handle, const Ogre::String &group, bool isManual, Ogre::ManualResourceLoader *loader, const Ogre::NameValuePairList *createParams) override
Create an AnnScriptFile.
virtual AnnScriptFilePtr load(const Ogre::String &name, const Ogre::String &group)
Load a resrouce via this manager.
static AnnScriptFileResourceManager & getSingleton()
Get singleton ref.
#define AnnDllExport
Definition: systemMacro.h:24
std::string sourceCode
Actual code of the file.
virtual ~AnnScriptFileResourceManager()
Destruct an AnnScriptFile resource manager.
static AnnScriptFileResourceManager * getSingletonPtr()
Get singleton ptr.
Ogre resource that contains the source code of a loaded .chai file.