Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
gmsh
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Larry Price
gmsh
Commits
f1a481eb
Commit
f1a481eb
authored
24 years ago
by
Jean-François Remacle
Browse files
Options
Downloads
Patches
Plain Diff
Gmsh Plugin's
parent
eac29927
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
Plugin/Makefile
+50
-0
50 additions, 0 deletions
Plugin/Makefile
Plugin/Plugin.cpp
+85
-0
85 additions, 0 deletions
Plugin/Plugin.cpp
Plugin/Plugin.h
+60
-0
60 additions, 0 deletions
Plugin/Plugin.h
with
195 additions
and
0 deletions
Plugin/Makefile
0 → 100644
+
50
−
0
View file @
f1a481eb
# $Id: Makefile,v 1.1 2001-03-04 19:55:25 remacle Exp $
#
# Makefile for "libAdapt.a"
#
.IGNORE
:
CC
=
c++
AR
=
ar ruvs
RM
=
rm
RANLIB
=
ranlib
LIB
=
../lib/libPlugin.a
INCLUDE
=
-I
../Common
-I
../DataStr
C_FLAGS
=
-g
-Wall
OS_FLAGS
=
VERSION_FLAGS
=
RMFLAGS
=
-f
CFLAGS
=
$(
C_FLAGS
)
$(
OS_FLAGS
)
$(
VERSION_FLAGS
)
$(
INCLUDE
)
SRC
=
Plugin.cpp
OBJ
=
$(
SRC:.cpp
=
.o
)
.SUFFIXES
:
.o .cpp
$(LIB)
:
$(OBJ)
$(
AR
)
$(
LIB
)
$(
OBJ
)
$(
RANLIB
)
$(
LIB
)
.cpp.o
:
$(
CC
)
$(
CFLAGS
)
-c
$<
clean
:
$(
RM
)
$(
RMFLAGS
)
*
.o
lint
:
$(
LINT
)
$(
CFLAGS
)
$(
SRC
)
depend
:
(
sed
'/^# DO NOT DELETE THIS LINE/q'
Makefile
&&
\
$(
CC
)
-MM
$(
CFLAGS
)
${
SRC
}
\
)
>
Makefile.new
cp
Makefile Makefile.bak
cp
Makefile.new Makefile
$(
RM
)
$(
RMFLAGS
)
Makefile.new
# DO NOT DELETE THIS LINE
This diff is collapsed.
Click to expand it.
Plugin/Plugin.cpp
0 → 100644
+
85
−
0
View file @
f1a481eb
#include
<stdio.h>
#include
<dlfcn.h>
#include
<map>
#include
"Plugin.h"
using
namespace
std
;
struct
ltstr
{
bool
operator
()(
const
char
*
s1
,
const
char
*
s2
)
const
{
return
strcmp
(
s1
,
s2
)
<
0
;
}
};
class
PluginContainer
{
public
:
typedef
map
<
char
*
,
GMSH_Plugin
*
,
ltstr
>::
iterator
iter
;
map
<
char
*
,
GMSH_Plugin
*
,
ltstr
>
m
;
iter
begin
()
{
return
m
.
begin
();}
iter
end
()
{
return
m
.
end
();}
iter
find
(
char
*
c
)
{
return
m
.
find
(
c
);}
};
GMSH_PluginManager
*
GMSH_PluginManager
::
instance
=
0
;
GMSH_PluginManager
::
GMSH_PluginManager
()
{
allPlugins
=
new
PluginContainer
;
}
GMSH_PluginManager
::~
GMSH_PluginManager
()
{
for
(
PluginContainer
::
iter
it
=
allPlugins
->
begin
();
it
!=
allPlugins
->
end
();
++
it
)
delete
(
*
it
).
second
;
delete
allPlugins
;
}
GMSH_PluginManager
*
GMSH_PluginManager
::
Instance
()
{
if
(
!
instance
)
{
instance
=
new
GMSH_PluginManager
;
}
return
instance
;
}
void
GMSH_PluginManager
::
RegisterDefaultPlugins
()
{
char
*
homeplugins
=
getenv
(
"GMSHPLUGINSHOME"
);
if
(
!
homeplugins
)
return
;
}
void
GMSH_PluginManager
::
AddPlugin
(
char
*
dirName
,
char
*
pluginName
)
{
char
dynamic_lib
[
1024
];
char
plugin_name
[
256
];
class
GMSH_Plugin
*
(
*
RegisterPlugin
)(
void
);
sprintf
(
dynamic_lib
,
"%s/%s.so"
,
dirName
,
pluginName
);
void
*
hlib
=
dlopen
(
dynamic_lib
,
RTLD_NOW
);
if
(
hlib
==
NULL
)
{
throw
dynamic_lib
;
}
RegisterPlugin
=
(
class
GMSH_Plugin
*
(
*
)(
void
))
dlsym
(
hlib
,
GMSH_PluginEntry
);
char
*
err
=
dlerror
();
if
(
err
!=
NULL
)
{
return
;
}
GMSH_Plugin
*
p
=
RegisterPlugin
();
p
->
hlib
=
hlib
;
p
->
getName
(
plugin_name
);
if
(
allPlugins
->
find
(
plugin_name
)
!=
allPlugins
->
end
())
{
return
;
}
allPlugins
->
m
[
plugin_name
]
=
p
;
}
This diff is collapsed.
Click to expand it.
Plugin/Plugin.h
0 → 100644
+
60
−
0
View file @
f1a481eb
#ifndef _PLUGIN_H_
#define _PLUGIN_H_
/*
The one who intend to create a plugin for gmsh have to
-) Create a dynamin lib (.so) containing 1 symbols
GMSH_Plugin * GMSH_RegisterPlugin ();
-) When there is an unacceptable error in the plugin,
just throw this, the plugin manager will be able to
catch the exception.
*/
const
char
*
GMSH_PluginEntry
=
"GMSH_RegisterPlugin"
;
class
PluginContainer
;
class
GMSH_Plugin
{
public
:
/*this is there for internal use, this variable will be
used by the PluginManager, just forget it*/
void
*
hlib
;
/* 3 kind of plugins, one for cad, one for mesh, one for postpro*/
typedef
enum
GMSH_PLUGIN_TYPE
{
GMSH_CAD_PLUGIN
,
GMSH_MESH_PLUGIN
,
GMSH_POSTPRO_PLUGIN
};
/* returns the type of plugin for downcasting GMSH_Plugin into
GMSH_CAD_Plugin, GMSH_Mesh_Plugin and GMSH_Post_Plugin */
virtual
GMSH_PLUGIN_TYPE
getType
()
const
=
0
;
virtual
void
getName
(
char
*
name
);
virtual
void
getInfos
(
char
*
author
,
char
*
copyright
,
char
*
help_text
)
const
=
0
;
/* When an error is thrown by the plugin, the plugin manager
will show the message and hopefully continue */
virtual
void
CatchErrorMessage
(
char
*
errorMessage
)
const
=
0
;
/* gmsh style option, ca be loaded, saved and set*/
virtual
void
SetOption
(
char
*
optionName
,
void
*
optionValue
)
=
0
;
virtual
int
getNbOptions
()
const
;
virtual
void
GetOption
(
char
*
optionName
,
void
*
optionValue
)
const
=
0
;
};
class
GMSH_PluginManager
{
/**
Registering all default plugins that are in $(GMSHPLUGINSHOME)
In fact, we will load all .so files in dir $(GMSHPLUGINSHOME)
*/
void
RegisterDefaultPlugins
();
GMSH_PluginManager
();
~
GMSH_PluginManager
();
static
GMSH_PluginManager
*
instance
;
PluginContainer
*
allPlugins
;
public
:
static
GMSH_PluginManager
*
Instance
();
/** Dynamically add a plugin pluginName.so in dirName*/
void
AddPlugin
(
char
*
dirName
,
char
*
pluginName
);
void
CallPlugin
(
char
*
name
);
void
DestroyPlugin
(
char
*
name
);
void
SetPluginOption
(
char
*
pluginName
,
char
*
option
,
void
*
value
);
};
#endif
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment