Merge branch 'devel/master' into devel/new_mesh
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / scripting / script-plugin-proxy.h
1 #ifndef __DALI_INTERNAL_SCRIPT_PLUGIN_PROXY_H__
2 #define __DALI_INTERNAL_SCRIPT_PLUGIN_PROXY_H__
3
4 /*
5  * Copyright (c) 2014 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-toolkit/devel-api/scripting/script-plugin.h>
22
23 namespace Dali
24 {
25
26 namespace Toolkit
27 {
28
29 namespace Internal
30 {
31
32 /**
33  * @brief Proxy class to dynamically load, use and unload script plugin.
34  *
35  *
36  */
37 class ScriptPluginProxy : public ScriptPlugin
38 {
39 public:
40
41   /**
42    * @brief Constructor
43    * @param sharedObjectName so file to load
44    */
45   ScriptPluginProxy( const std::string& sharedObjectName);
46
47   /**
48    *  @brief destructor
49    */
50   virtual ~ScriptPluginProxy();
51
52   /**
53    * Set engine configuration flags
54    * @param [in] flags string. Format dependent on the scripting engine.
55    */
56   virtual void SetFlags( const std::string& flags );
57
58   /**
59    * @brief Exececute the buffer contents as a script
60    * @param [in] buffer script file contents
61    * @param [in] filename a nominal name for the buffer contents.
62    * @note filename extension may be used to disambiguate script language
63    * @return true on success, false on failure
64    *
65    */
66   virtual bool ExecuteBuffer( const std::string& buffer, const std::string& filename );
67
68   /**
69    * @brief  execture the file as a script
70    * @param [in] filename the filename to read and execute
71    * @return true on success, false on failure
72    */
73   virtual bool ExecuteFile( const std::string& fileName );
74
75   /**
76    * @brief check if the plugin is initialized
77    * @return true if it's initialized
78    */
79   bool IsInitialized() const;
80
81 private:
82   /**
83    * @brief Dynamically loads the script plugin.
84    */
85   void Initialize();
86
87   /**
88    * @brief Unloads the script plugin.
89    */
90   void UnInitialize();
91
92 private:
93
94   void* mLibHandle;
95   ScriptPlugin::Create* mCreatePluginFunctionPtr;
96   ScriptPlugin::Destroy* mDestroyPluginFunctionPtr;
97   ScriptPlugin* mScriptingPlugin;
98   std::string mSharedObjectName;
99   bool mIsInitialized;
100
101 };
102
103 } // namespace Adaptor
104
105 } // namespace Internal
106
107 } // namespace Dali
108
109 #endif // __DALI_INTERNAL_SCRIPT_PLUGIN_PROXY_H__