00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00057
00058
00059
00060 #ifndef __MX_FRAMEWORK_H__
00061 #define __MX_FRAMEWORK_H__
00062
00063
00064
00065
00066 #if defined(_MSC_VER) && !defined(MX_STATIC_LIB)
00067 #ifdef MX_FRAMEWORK_API_WINDOWS_EXPORTS
00068 #define MX_FRAMEWORK_API __declspec(dllexport)
00069 #else
00070 #define MX_FRAMEWORK_API __declspec(dllimport)
00071 #endif
00072 #else
00073 #define MX_FRAMEWORK_API
00074 #endif // _MSC_VER
00075
00076
00077
00078 #include <mx_error_codes.h>
00079 #include <interfaces/IComponent.h>
00080 #include <mxm/core/mxmObject.h>
00081 #include <mxm/core/mxmString.h>
00082 #include <mxm/core/mxmPerlStyleHash.h>
00083 #include <mxm/core/mxmApplication.h>
00084
00085 #ifdef MX_PLATFORM_WINDOWS
00086 #define WIN32_LEAN_AND_MEAN
00087 #undef UNICODE
00088 #include <windows.h>
00089 #include <direct.h>
00090 #endif
00091
00092
00093 namespace mx {
00094
00096
00106 class MX_FRAMEWORK_API Framework : public mxmObject {
00107
00108 public:
00110 static const mxm::flags HarmlessSelectionFailures = 1;
00111 static const char *IdHintKey;
00112 static const char *ObsoletesHintKey;
00113
00114 public:
00116 class MX_FRAMEWORK_API ComponentDescriptor : public mxmPerlStyleHash {
00117 private:
00118 void *StableABIDataExtension;
00119 public:
00121 void addRequiredInterface(const mxmString &interface_id,
00122 const mxmStringList &interface_capabilities);
00124 void addRequiredInterface(const mxmString &interface_id,
00125 const mxmString &interface_capability = "");
00126 };
00127
00128 private:
00129 class ComponentEntry : public mxmObject {
00130 public:
00131 mxm::smart<mx::IComponent> spComponent;
00132 bool RuledOut;
00133 public:
00134 ComponentEntry();
00135 };
00136 class ComponentPackEntry : public mxmObject {
00137 public:
00138 mxmString Filename;
00139 #ifdef MX_PLATFORM_WINDOWS
00140 public:
00141 HINSTANCE DLLHandle;
00142 #else
00143 public:
00144 void *SharedObjectHandle;
00145 #endif
00146 public:
00147 ~ComponentPackEntry();
00148 };
00149
00150 private:
00151 static Framework* s_pFramework;
00152
00153 private:
00154 mxmList LoadedComponentPacks;
00155 mxmList ComponentList;
00156 void *StableABIDataExtension;
00157
00158 public:
00160 static Framework* framework();
00161
00164 static mx::EErrorCode getComponentInterface(const ComponentDescriptor &cd,
00165 mxm::smart<mx::IComponent>
00166 &spInterface);
00168 static mx::EErrorCode getComponentInterface(const char* InterfaceId,
00169 mxm::smart<mx::IComponent>
00170 &spInterface,
00171 const mxmStringList&
00172 Capabilities);
00174 static mx::EErrorCode getComponentInterface(const char* InterfaceId,
00175 mxm::smart<mx::IComponent>
00176 &spInterface,
00177 const mxmString& Capability
00178 = "");
00179
00182 static mxm::smart<IComponent> getComponent(const ComponentDescriptor &cd);
00184 static mxm::smart<IComponent> getComponent(const mxmString &interface_id,
00185 const mxmStringList
00186 &interface_capabilities);
00188 static mxm::smart<IComponent> getComponent(const mxmString &interface_id,
00189 const mxmString
00190 &interface_capability
00191 = "");
00192
00196 static IComponent *newComponentInstance(const ComponentDescriptor &cd,
00197 mxm::flags selection_flags = 0);
00199 static IComponent *newComponentInstance(const mxmString &interface_id,
00200 const mxmStringList
00201 &interface_capabilities,
00202 mxm::flags selection_flags = 0);
00204 static IComponent *newComponentInstance(const mxmString &interface_id,
00205 const mxmString
00206 &interface_capability = "",
00207 mxm::flags selection_flags = 0);
00208
00209 public:
00211 Framework(mxmList *statically_linked_components = 0);
00212 ~Framework();
00213
00214 public:
00216 int numComponents();
00218 mxm::smart<mxmStringList> enumerateComponents();
00219
00220 private:
00222 int bindComponentPacks();
00224 int useStaticallyLinkedComponents(mxmList *statically_linked_components);
00227 bool loadSharedLibrary(const mxmString &filename);
00229 mx::EErrorCode provideComponent(const ComponentDescriptor &cd,
00230 mxm::smart<mx::IComponent> &spInterface,
00231 bool &instantiated_new);
00232 };
00233
00234 };
00235
00236
00237
00238 #endif // __MX_FRAMEWORK_H__