Merge "Add descriptions and example codes" into devel/master
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / devel-api / scripting / script-plugin.h
1 #ifndef __DALI_SCRIPT_PLUGIN_H__
2 #define __DALI_SCRIPT_PLUGIN_H__
3
4 /*
5  * Copyright (c) 2015 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20
21 #include <dali/public-api/common/dali-common.h>
22 #include <string>
23
24 namespace Dali
25 {
26
27 namespace Toolkit
28 {
29
30 /**
31  * @brief Abstract interface to provide scripting support.
32  *
33  * A plugin must export the following functions to create / destroy the object
34  * CreateScriptPlugin()  // returns a pointer to a ScriptPlugin object
35  * DestroyScriptPlugin() // destroys the plugin
36  */
37 class DALI_IMPORT_API ScriptPlugin
38 {
39 public:
40
41
42   /**
43    * Function pointer called in toolkit to create a ScriptPlugin plugin instance.
44    * @return Pointer to the newly created plugin object
45    */
46   typedef ScriptPlugin* Create();
47
48   /**
49    * Function pointer called in toolkit to Unload the plugin.
50    * @param plugin  The plugin object created and returned by CreateScriptPluginPlugin().
51    */
52   typedef void Destroy(ScriptPlugin* plugin);
53
54   /**
55    * virtual Destructor.
56    */
57   virtual ~ScriptPlugin() {};
58
59   /**
60    * Set engine configuration flags
61    * @param [in] flags string. Format dependent on the scripting engine.
62    */
63   virtual void SetFlags(const std::string& flags) = 0;
64
65   /**
66    * Exec buffer contents as a script
67    * @param buffer script file contents
68    * @param filename a nominal name for the buffer contents.
69    * filename extension may be used to disambiguate script language
70    * @return true on success, false on failure
71    *
72    */
73   virtual bool ExecuteBuffer(const std::string& buffer, const std::string& filename) = 0;
74
75   /**
76    * Exec file as a script
77    * @param filename the filename to read and execute
78    * @return true on success, false on failure
79    */
80   virtual bool ExecuteFile(const std::string& filename) = 0;
81
82 }; // class ScriptPlugin
83
84 } // namespace Toolkit
85
86 } // namespace Dali
87
88 #endif // __DALI_SCRIPT_PLUGIN_H__