/home/dko/projects/mobilec/trunk/src/win32/LibMC.net/LibMC/MCExports.cs

Go to the documentation of this file.
00001 using System;
00002 using System.Collections.Generic;
00003 using System.Text;
00004 using System.Runtime.InteropServices;
00005 
00010 namespace LibMC
00011 {
00012     public partial class MCAgency
00013     {
00014         //private const String mcdll = "C:\\mobilec\\src\\win32\\vcnet2005\\dll debug\\libmcd.dll";
00015         private const String mcdll = 
00016 #if DEBUG
00017             "libmcd.dll";
00018 #else
00019             "libmc.dll";
00020 #endif
00021 
00022         [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
00023         internal struct MCAgency_t
00024         {
00025             int client;
00026             int server;
00027             String hostName;                     
00028             String filename;
00029             int portno;                         
00030             int portnoc;
00031             IntPtr mc_platform;  
00032             int default_agentstatus;            
00033             int threads;                        
00034             int enable_security;                
00035             //int stack_size[MC_THREAD_ALL];
00036             [MarshalAs(UnmanagedType.ByValArray, SizeConst = 5)]
00037             int[] stack_size;
00038             int last_error;
00039         };
00040 
00041         [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
00042         internal struct MCAgencyOptions_t
00043         {
00044             int threads;              
00045             int default_agent_status; 
00046             int modified;             
00047             int enable_security;      
00048             [MarshalAs(UnmanagedType.ByValArray, SizeConst = 5)]
00049             /* Following are some thread stack size options: unix/pthreads only! */
00050             int[] stack_size; 
00051         };
00052 
00060         [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
00061         internal struct ChOptions_t
00062         {
00063             public int shelltype;        
00064             /* int chrc; */       /* deprecated, use default value */
00065             /* char *chrcname; */ /* deprecated, use default value  */
00066             public String chhome;         
00068             /* char *chmtdir; */  /* directory for dynamically loaded libs chmt1.dl, chmt2.dl etc. 
00069                                     deprecated, use default value*/
00070         };
00071 
00079         public enum MC_ThreadIndex_e
00080         {
00081             MC_THREAD_DF = 0, 
00082             MC_THREAD_AMS,    
00083             MC_THREAD_ACC,    
00084             MC_THREAD_CP,     
00085             MC_THREAD_AGENT,  
00086             MC_THREAD_ALL
00087         };
00088 
00094         public enum MC_SteerCommand_e {
00095           MC_RUN = 0,     
00096           MC_SUSPEND,     
00097           MC_RESTART,     
00098           MC_STOP         
00099         };
00100 
00111         enum MC_Signal_e{
00112             MC_NO_SIGNAL       = 0x00,
00113             MC_RECV_CONNECTION = 0x01,
00114             MC_RECV_MESSAGE    = 0x02,
00115             MC_RECV_AGENT      = 0x04,
00116             MC_RECV_RETURN     = 0x08,
00117             MC_EXEC_AGENT      = 0x0F,
00118             MC_ALL_SIGNALS     = 0x10
00119         };
00120 
00121         /*
00122          * Functions to import from libmc.dll
00123          */
00124         // Basic agency functions
00125         [DllImport(mcdll, EntryPoint = "MC_Initialize")]
00126         private static extern IntPtr _MC_Initialize(int port, ref MCAgencyOptions_t options);
00127         [DllImport(mcdll, EntryPoint = "MC_End")]
00128         private static extern int _MC_End(IntPtr agency);//ref MCAgency_t agency);
00129         [DllImport(mcdll, EntryPoint = "MC_ChInitializeOptions")]
00130         private static extern int _MC_ChInitializeOptions(IntPtr agency, ChOptions_t options);
00131         [DllImport(mcdll, EntryPoint = "MC_InitializeAgencyOptions")]
00132         private static extern int _MC_InitializeAgencyOptions(ref MCAgencyOptions_t options);
00133         [DllImport(mcdll, EntryPoint = "MC_SetThreadsAllOn")]
00134         private static extern int _MC_SetThreadsAllOn(ref MCAgencyOptions_t options);
00135         [DllImport(mcdll, EntryPoint = "MC_SetThreadsAllOff")]
00136         private static extern int _MC_SetThreadsAllOff(ref MCAgencyOptions_t options);
00137         [DllImport(mcdll, EntryPoint = "MC_SetThreadOn")]
00138         private static extern int _MC_SetThreadOn(ref MCAgencyOptions_t options, MC_ThreadIndex_e index);
00139         [DllImport(mcdll, EntryPoint = "MC_SetThreadOff")]
00140         private static extern int _MC_SetThreadOff(ref MCAgencyOptions_t options, MC_ThreadIndex_e index);
00141         [DllImport(mcdll, EntryPoint = "MC_HaltAgency")]
00142         private static extern int _MC_HaltAgency(IntPtr agency);
00143         [DllImport(mcdll, EntryPoint = "MC_ResumeAgency")]
00144         private static extern int _MC_ResumeAgency(IntPtr agency);
00145         [DllImport(mcdll, EntryPoint = "MC_SetDefaultAgentStatus")]
00146         private static extern int _MC_SetDefaultAgentStatus(IntPtr agency, MCAgent.MC_AgentStatus_e status);
00147         [DllImport(mcdll, EntryPoint = "MC_WaitRetrieveAgent")]
00148         private static extern IntPtr _MC_WaitRetrieveAgent(IntPtr agency);
00149         [DllImport(mcdll, EntryPoint = "MC_WaitAgent")]
00150         private static extern int _MC_WaitAgent(IntPtr agency);
00151         [DllImport(mcdll, EntryPoint = "MC_ MainLoop")]
00152         private static extern int _MC_MainLoop(IntPtr agency);
00153 
00154         // Migration functions
00155         [DllImport(mcdll, EntryPoint = "MC_SendAgentMigrationMessageFile")]
00156         private static extern int _MC_SendAgentMigrationMessageFile(IntPtr agency, String filename, String hostname, int port);
00157         [DllImport(mcdll, EntryPoint = "MC_SendAgentMigrationMessage")]
00158         private static extern int _MC_SendAgentMigrationMessage(IntPtr agency, String message, String hostname, int port);
00159 
00160         // Signals and threading
00161         [DllImport(mcdll, EntryPoint = "MC_CondBroadcast")]
00162         private static extern int _MC_CondBroadcast(IntPtr agency, int id);
00163         [DllImport(mcdll, EntryPoint = "MC_CondSignal")]
00164         private static extern int _MC_CondSignal(IntPtr agency, int id);
00165         [DllImport(mcdll, EntryPoint = "MC_CondReset")]
00166         private static extern int _MC_CondReset(IntPtr agency, int id);
00167         [DllImport(mcdll, EntryPoint = "MC_CondWait")]
00168         private static extern int _MC_CondWait(IntPtr agency, int id);
00169         [DllImport(mcdll, EntryPoint = "MC_MutexLock")]
00170         private static extern int _MC_MutexLock(IntPtr agency, int id);
00171         [DllImport(mcdll, EntryPoint = "MC_MutexUnlock")]
00172         private static extern int _MC_MutexUnlock(IntPtr agency, int id);
00173         [DllImport(mcdll, EntryPoint = "MC_SemaphorePost")]
00174         private static extern int _MC_SemaphorePost(IntPtr agency, int id);
00175         [DllImport(mcdll, EntryPoint = "MC_SemaphoreWait")]
00176         private static extern int _MC_SemaphoreWait(IntPtr agency, int id);
00177         [DllImport(mcdll, EntryPoint = "MC_ResetSignal")]
00178         private static extern int _MC_ResetSignal(IntPtr agency);
00179         [DllImport(mcdll, EntryPoint = "MC_SyncDelete")]
00180         private static extern int _MC_SyncDelete(IntPtr agency, int id);
00181         [DllImport(mcdll, EntryPoint = "MC_SyncInit")]
00182         private static extern int _MC_SyncInit(IntPtr agency, int id);
00183         [DllImport(mcdll, EntryPoint = "MC_WaitSignal")]
00184         private static extern int _MC_WaitSignal(IntPtr agency, int signals);
00185         [DllImport(mcdll, EntryPoint = "MC_BarrierDelete")]
00186         private static extern int _MC_BarrierDelete(IntPtr agency, int id);
00187         [DllImport(mcdll, EntryPoint = "MC_BarrierInit")]
00188         private static extern int _MC_BarrierInit(IntPtr agency, int id, int num_procs);
00189 
00190         //Steering functions
00191         [DllImport(mcdll, EntryPoint = "MC_SteerControl")]
00192         private static extern MC_SteerCommand_e _MC_SteerControl();
00193         [DllImport(mcdll, EntryPoint = "MC_Steer")]
00194         private static extern int _MC_Steer(IntPtr agency, IntPtr funcptr, IntPtr arg);
00195         /*private static extern int _MC_Steer(IntPtr agency, int (*funcptr)(void* data), void *arg);*/
00196 
00197         // Services
00198         [DllImport(mcdll, EntryPoint = "MC_RegisterService")]
00199         private static extern int _MC_RegisterService(IntPtr agency, IntPtr agent, int agentID, String agentName, String[] serviceNames, int numServices);
00200         [DllImport(mcdll, EntryPoint = "MC_SearchForService")]
00201         private static extern int _MC_SearchForService(IntPtr agency, String searchString, IntPtr agentNames, IntPtr serviceNames, IntPtr agentIDs, IntPtr numResults);
00202         /*private static extern int _MC_SearchForService(IntPtr agency, String searchString, char*** agentNames, char*** serviceNames, int** agentIDs, int* numResults);*/
00203 
00204         // Agent-related agency functions
00205         [DllImport(mcdll, EntryPoint = "MC_AddAgent")]
00206         private static extern int _MC_AddAgent(IntPtr agency, IntPtr agent);
00207         [DllImport(mcdll, EntryPoint = "MC_DeleteAgent")]
00208         internal static extern int _MC_DeleteAgent(IntPtr agent);
00209         [DllImport(mcdll, EntryPoint = "MC_FindAgentByName")]
00210         private static extern IntPtr _MC_FindAgentByName(IntPtr agency, String name);
00211         [DllImport(mcdll, EntryPoint = "MC_FindAgentByID")]
00212         private static extern IntPtr _MC_FindAgentByID(IntPtr agency, int ID);
00213         [DllImport(mcdll, EntryPoint = "MC_RetrieveAgent")]
00214         private static extern IntPtr _MC_RetrieveAgent(IntPtr agency);
00215 
00216         // Agent member functions
00217         [DllImport(mcdll, EntryPoint = "MC_GetAgentID")]
00218         internal static extern int _MC_GetAgentID(IntPtr agent);
00219         [DllImport(mcdll, EntryPoint = "MC_GetAgentName")]
00220         internal static extern String _MC_GetAgentName(IntPtr agent);
00221         [DllImport(mcdll, EntryPoint = "MC_GetAgentNumTasks")]
00222         internal static extern int _MC_GetAgentNumTasks(IntPtr agent);
00223         [DllImport(mcdll, EntryPoint = "MC_GetAgentStatus")]
00224         internal static extern MCAgent.MC_AgentStatus_e _MC_GetAgentStatus(IntPtr agent);
00225         [DllImport(mcdll, EntryPoint = "MC_GetAgentType")]
00226         internal static extern MCAgent.MC_AgentType_e _MC_GetAgentType(IntPtr agent);
00227         [DllImport(mcdll, EntryPoint = "MC_GetAgentXMLString")]
00228         internal static extern String _MC_GetAgentXMLString(IntPtr agent);
00229         [DllImport(mcdll, EntryPoint = "MC_PrintAgentCode")]
00230         internal static extern int _MC_PrintAgentCode(IntPtr agent);
00231         [DllImport(mcdll, EntryPoint = "MC_RetrieveAgentCode")]
00232         internal static extern String _MC_RetrieveAgentCode(IntPtr agent);
00233         [DllImport(mcdll, EntryPoint = "MC_SetAgentStatus")]
00234         internal static extern int _MC_SetAgentStatus(IntPtr agent, MCAgent.MC_AgentStatus_e status);
00235         [DllImport(mcdll, EntryPoint = "MC_TerminateAgent")]
00236         internal static extern int _MC_TerminateAgent(IntPtr agent);
00237 
00238         [DllImport(mcdll, EntryPoint = "MC_CallAgentFunc")]
00239         internal static extern int _MC_CallAgentFunc(IntPtr agent, String funcName, IntPtr returnVal, IntPtr varg);
00240         [DllImport(mcdll, EntryPoint = "MC_GetAgentExecEngine")]
00241         internal static extern IntPtr _MC_GetAgentExecEngine(IntPtr agent);
00242         [DllImport(mcdll, EntryPoint = "MC_GetAgentReturnData")]
00243         internal static extern int _MC_GetAgentReturnData(IntPtr agent, int task_num, IntPtr data, IntPtr dim, IntPtr extent);
00244         /*internal static extern int _MC_GetAgentReturnData(IntPtr agent, int task_num, void **data, int *dim, int **extent);*/
00245 
00246         // If the return is an Intptr, it's really a fipa_acl_message_s pointer.
00247         // If an argument is IntPtr, it's a pointer to a fipa_acl_message_s
00248         // ACL functions
00249         [DllImport(mcdll, EntryPoint = "MC_AclNew")]
00250         internal static extern IntPtr _MC_AclNew();
00251         [DllImport(mcdll, EntryPoint = "MC_AclPost")]
00252         internal static extern int _MC_AclPost(IntPtr agent, IntPtr message);
00253         [DllImport(mcdll, EntryPoint = "MC_AclReply")]
00254         internal static extern IntPtr _MC_AclReply(IntPtr acl_message);
00255         [DllImport(mcdll, EntryPoint = "MC_AclRetrieve")]
00256         internal static extern IntPtr _MC_AclRetrieve(IntPtr agent);
00257         [DllImport(mcdll, EntryPoint = "MC_AclSend")]
00258         internal static extern int _MC_AclSend(IntPtr agency, IntPtr acl_message);
00259         [DllImport(mcdll, EntryPoint = "MC_AclWaitRetrieve")]
00260         internal static extern IntPtr _MC_AclWaitRetrieve(IntPtr agent);
00261 
00262         /* ACL Helper Functions Here */
00263         [DllImport(mcdll, EntryPoint = "MC_AclSetPerformative")]
00264         internal static extern int _MC_AclSetPerformative(IntPtr acl, MCAclMessage.MC_FipaPerformative_e performative);
00265         [DllImport(mcdll, EntryPoint = "MC_AclSetSender")]
00266         internal static extern int _MC_AclSetSender(IntPtr acl, String name, String address);
00267         [DllImport(mcdll, EntryPoint = "MC_AclAddReceiver")]
00268         internal static extern int _MC_AclAddReceiver(IntPtr acl, String name, String address);
00269         [DllImport(mcdll, EntryPoint = "MC_AclAddReplyTo")]
00270         internal static extern int _MC_AclAddReplyTo(IntPtr acl, String name, String address);
00271         [DllImport(mcdll, EntryPoint = "MC_AclSetContent")]
00272         internal static extern int _MC_AclSetContent(IntPtr acl, String content);
00273         [DllImport(mcdll, EntryPoint = "MC_AclDestroy")]
00274         internal static extern int _MC_AclDestroy(IntPtr acl);
00275 
00276         /*
00277          * List of functions to import
00278         //struct fipa_acl_message_s* MC_AclNew(void);
00279         //int MC_AclPost(MCAgent_t agent, struct fipa_acl_message_s* message);
00280         //struct fipa_acl_message_s* MC_AclReply(struct fipa_acl_message_s* acl_message);
00281         //struct fipa_acl_message_s* MC_AclRetrieve(MCAgent_t agent);
00282         //int MC_AclSend(MCAgency_t attr, struct fipa_acl_message_s* acl);
00283         //struct fipa_acl_message_s* MC_AclWaitRetrieve(MCAgent_t agent);
00284         //int MC_AddAgent(MCAgency_t attr, MCAgent_t agent);
00285         //int MC_BarrierDelete(MCAgency_t attr, int id);
00286         //int MC_BarrierInit(MCAgency_t attr, int id, int num_procs);
00287         //int MC_ChInitializeOptions(MCAgency_t attr, ChOptions_t *options);
00288         //int MC_CallAgentFunc(MCAgent_t agent, const char* funcName, void* returnVal, void* varg);
00289         //int MC_CondBroadcast(MCAgency_t attr, int id);
00290         //int MC_CondSignal(MCAgency_t attr, int id);
00291         //int MC_CondReset(MCAgency_t attr, int id);
00292         //int MC_CondWait(MCAgency_t attr, int id);
00293         //int MC_DeleteAgent(MCAgent_t agent);
00294         //int MC_End(MCAgency_t attr);
00295         //MCAgent_t MC_FindAgentByName(MCAgency_t attr, const char *name);
00296         //MCAgent_t MC_FindAgentByID(MCAgency_t attr, int ID);
00297         //void* MC_GetAgentExecEngine(MCAgent_t agent);
00298         //int MC_GetAgentID(MCAgent_t agent);
00299         //char* MC_GetAgentName(MCAgent_t agent);
00300         //int MC_GetAgentNumTasks(MCAgent_t agent);
00301         //int MC_GetAgentReturnData(MCAgent_t agent, int task_num, void **data, int *dim, int **extent);
00302         //int MC_GetAgentStatus(MCAgent_t agent);
00303         //enum MC_AgentType_e MC_GetAgentType(MCAgent_t agent);
00304         //char* MC_GetAgentXMLString(MCAgent_t agent);
00305         //int MC_HaltAgency(MCAgency_t agency);
00306         //MCAgency_t MC_Initialize(int port, MCAgencyOptions_t *options);
00307         //int MC_InitializeAgencyOptions(struct MCAgencyOptions_s* options);
00308         //int MC_MutexLock(MCAgency_t attr, int id);
00309         //int MC_MutexUnlock(MCAgency_t attr, int id);
00310         //int MC_RegisterService(MCAgency_t agency, MCAgent_t agent, int agentID, const char *agentName, char **serviceNames, int numServices);
00311         //int MC_ResumeAgency(MCAgency_t agency);
00312         //MCAgent_t MC_RetrieveAgent(MCAgency_t attr);
00313         //int MC_SemaphorePost(MCAgency_t attr, int id);
00314         //int MC_SemaphoreWait(MCAgency_t attr, int id);
00315         //int MC_SetDefaultAgentStatus(MCAgency_t agency, enum MC_AgentStatus_e status);
00316         //int MC_SetThreadOn(MCAgencyOptions_t *options, enum MC_ThreadIndex_e index);
00317         //int MC_SetThreadsAllOn(MCAgencyOptions_t* options);
00318         //int MC_SetThreadOff(MCAgencyOptions_t *options, enum MC_ThreadIndex_e index );
00319         //int MC_SetThreadsAllOff(MCAgencyOptions_t* options);
00320         //int MC_PrintAgentCode(MCAgent_t agent);
00321         //char * MC_RetrieveAgentCode(MCAgent_t agent);
00322         //int MC_ResetSignal(MCAgency_t attr);
00323         //int MC_SearchForService(MCAgency_t attr, const char *searchString, char*** agentNames, char*** serviceNames, int** agentIDs, int* numResults);
00324         //int MC_SendAgentMigrationMessage(MCAgency_t attr, const char *message, const char *hostname, int port);
00325         //int MC_SendAgentMigrationMessageFile(MCAgency_t attr, const char *filename, const char *hostname, int port);
00326         //int MC_SetAgentStatus(MCAgent_t agent, int status);
00327         //int MC_Steer(MCAgency_t attr, int (*funcptr)(void* data), void *arg);
00328         //enum MC_SteerCommand_e MC_SteerControl(void);
00329         //int MC_SyncDelete(MCAgency_t attr, int id);
00330         //int MC_SyncInit(MCAgency_t attr, int id);
00331         //int MC_TerminateAgent(MCAgent_t agent);
00332         //int MC_WaitAgent(MCAgency_t attr);
00333         //MCAgent_t MC_WaitRetrieveAgent(MCAgency_t attr);
00334         //int MC_WaitSignal(MCAgency_t attr, int signals);
00335         */
00336     }
00337 }

Generated on Mon Jun 23 16:01:12 2008 for Mobile-C by  doxygen 1.5.4