Framework.h

00001 //           ///          //                                  C++ Cross Platform
00002 //          /////        ////
00003 //         /// XXX     XXX ///            ///////////   /////////     ///   ///
00004 //        ///    XXX XXX    ///         ///             ///    ///   ///  ///
00005 //       ///       XXX       ///         /////////     ///      //  //////
00006 //      ///      XXX XXX      ///               ///   ///    ///   ///  ///
00007 //     ////    XXX     XXX    ////    ////////////  //////////    ///   ///
00008 //    ////                     ////
00009 //   ////  M  O  B  O  T  I  X  ////////////////////////////////////////////////
00010 //  //// Security Vision Systems //////////////////////////////////////////////
00011 //
00012 //  $Author: khe_admin $
00013 //  $LastChangedBy: khe_admin $
00014 //  $LastChangedDate: 2007-06-29 15:34:53 +0200 (Fri, 29 Jun 2007) $
00015 //  $HeadURL: http://svn.mobotix.net/svn/mxsdk/src/Framework/trunk/include/Framework/Framework.h $
00016 //
00018      //
00019      //  MOBOTIX MxPEG SDK
00020      //
00021      //  This file belongs to the C++ library released as part of the MxPEG SDK.
00022      //
00023      //  This software is licenced under the BSD licence,
00024      //  http://www.opensource.org/licenses/bsd-license.php
00025      //
00026      //  Copyright (c) 2005 - 2007, MOBOTIX AG
00027      //  All rights reserved.
00028      //
00029      //  Redistribution and use in source and binary forms, with or without
00030      //  modification, are permitted provided that the following conditions are
00031      //  met:
00032      //
00033      //  - Redistributions of source code must retain the above copyright
00034      //    notice, this list of conditions and the following disclaimer.
00035      //
00036      //  - Redistributions in binary form must reproduce the above copyright
00037      //    notice, this list of conditions and the following disclaimer in the
00038      //    documentation and/or other materials provided with the distribution.
00039      //
00040      //  - Neither the name of MOBOTIX AG nor the names of its contributors may
00041      //    be used to endorse or promote products derived from this software
00042      //    without specific prior written permission.
00043      //
00044      //  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00045      //  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00046      //  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
00047      //  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
00048      //  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
00049      //  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
00050      //  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
00051      //  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
00052      //  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00053      //  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00054      //  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00055      //
00057 
00058 
00059 
00060 #ifndef __MX_FRAMEWORK_H__
00061 #define __MX_FRAMEWORK_H__
00062 
00063 
00064 
00065 // MS Visual C++ stuff...
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;      // when used during the component selection process
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();   // unloads the dynamic library
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 };   // mx namespace
00235 
00236 
00237 
00238 #endif  // __MX_FRAMEWORK_H__

Generated on Fri Jun 29 17:21:04 2007 for MxPEG SDK by  doxygen 1.4.6