cdev-1.7.2n
This commit is contained in:
26
test/cdevCollection/Makefile
Executable file
26
test/cdevCollection/Makefile
Executable file
@@ -0,0 +1,26 @@
|
||||
########################################################################
|
||||
# Makefile for shared object
|
||||
########################################################################
|
||||
CDEVROOT = $(CDEV)
|
||||
include $(CDEVROOT)/examples/Makefile.common
|
||||
|
||||
CXXEXTRA = $(CLASS_INCLUDES) $(EPICSINCLUDES)
|
||||
EPICSLIBS = -L$(EPICSLIB) -lCom -lDb -lca
|
||||
|
||||
LIBS = -L$(CDEVLIB) -lcdev -lEpicsCa -lSampleService -lSimpleService \
|
||||
$(EPICSLIBS) -lm -ly -ll
|
||||
|
||||
TARGETS = attachCollection detachCollection add1 add2 add3 add4 add5 \
|
||||
remove1 remove2 remove3 remove4 remove5 getList
|
||||
|
||||
targets: $(TARGETS)
|
||||
|
||||
% : %.cc
|
||||
@echo "=> Building $@"
|
||||
@rm -f $@
|
||||
@$(PROOF) $(CXX) $(CXXFLAGS) $(CXXEXTRA) $^ $(LIBS) -o $@
|
||||
@rm -rf ptrepository
|
||||
|
||||
clean:
|
||||
@rm -rf *.o *.a *~ *.?.? TC.Cache $(TARGETS) core ptrepository
|
||||
|
||||
21
test/cdevCollection/add1.cc
Executable file
21
test/cdevCollection/add1.cc
Executable file
@@ -0,0 +1,21 @@
|
||||
#include <cdevCollection.h>
|
||||
|
||||
void main ( void )
|
||||
{
|
||||
/**************************************************************
|
||||
* Attach to an undefined cdevCollection device and then add
|
||||
* the cdevDevice "device0" to it.
|
||||
**************************************************************/
|
||||
cdevCollection & brandNew = cdevCollection::attachRef("brandNew");
|
||||
brandNew.add("device0");
|
||||
|
||||
/**************************************************************
|
||||
* Use the getList method to obtain the array of names that are
|
||||
* currently stored in the cdevCollection and display them.
|
||||
* Note that the list (not the list items) msut be deleted by
|
||||
* the caller.
|
||||
**************************************************************/
|
||||
char ** list = brandNew.getList();
|
||||
for(char **s = list; *s!=NULL; s++) printf("%s\n", *s);
|
||||
delete list;
|
||||
}
|
||||
21
test/cdevCollection/add2.cc
Executable file
21
test/cdevCollection/add2.cc
Executable file
@@ -0,0 +1,21 @@
|
||||
#include <cdevCollection.h>
|
||||
|
||||
void main ( void )
|
||||
{
|
||||
/**************************************************************
|
||||
* Attach to the cdevCollection "brandNew" and add four device
|
||||
* names to it.
|
||||
**************************************************************/
|
||||
cdevCollection & brandNew = cdevCollection::attachRef("brandNew");
|
||||
brandNew.add(4, "device0", "device1", "device2", "device3");
|
||||
|
||||
/**************************************************************
|
||||
* Use the getList method to obtain the array of names that are
|
||||
* currently stored in the cdevCollection and display them.
|
||||
* Note that the list (not the list items) msut be deleted by
|
||||
* the caller.
|
||||
**************************************************************/
|
||||
char ** list = brandNew.getList();
|
||||
for(char **s = list; *s!=NULL; s++) printf("%s\n", *s);
|
||||
delete list;
|
||||
}
|
||||
23
test/cdevCollection/add3.cc
Executable file
23
test/cdevCollection/add3.cc
Executable file
@@ -0,0 +1,23 @@
|
||||
#include <cdevCollection.h>
|
||||
|
||||
char * devices[] = {"device0", "device1", "device2", "device3"};
|
||||
|
||||
void main ( void )
|
||||
{
|
||||
/**************************************************************
|
||||
* Attach to the cdevCollection "brandNew" and add four device
|
||||
* names to it.
|
||||
**************************************************************/
|
||||
cdevCollection & brandNew = cdevCollection::attachRef("brandNew");
|
||||
brandNew.add(4, devices);
|
||||
|
||||
/**************************************************************
|
||||
* Use the getList method to obtain the array of names that are
|
||||
* currently stored in the cdevCollection and display them.
|
||||
* Note that the list (not the list items) msut be deleted by
|
||||
* the caller.
|
||||
**************************************************************/
|
||||
char ** list = brandNew.getList();
|
||||
for(char **s = list; *s!=NULL; s++) printf("%s\n", *s);
|
||||
delete list;
|
||||
}
|
||||
23
test/cdevCollection/add4.cc
Executable file
23
test/cdevCollection/add4.cc
Executable file
@@ -0,0 +1,23 @@
|
||||
#include <cdevCollection.h>
|
||||
|
||||
char * devices[] = {"device0", "device1", "device2", NULL};
|
||||
|
||||
void main ( void )
|
||||
{
|
||||
/**************************************************************
|
||||
* Attach to the cdevCollection "brandNew" and add a NULL
|
||||
* terminated list of devices to it.
|
||||
**************************************************************/
|
||||
cdevCollection & brandNew = cdevCollection::attachRef("brandNew");
|
||||
brandNew.add(devices);
|
||||
|
||||
/**************************************************************
|
||||
* Use the getList method to obtain the array of names that are
|
||||
* currently stored in the cdevCollection and display them.
|
||||
* Note that the list (not the list items) msut be deleted by
|
||||
* the caller.
|
||||
**************************************************************/
|
||||
char ** list = brandNew.getList();
|
||||
for(char **s = list; *s!=NULL; s++) printf("%s\n", *s);
|
||||
delete list;
|
||||
}
|
||||
21
test/cdevCollection/add5.cc
Executable file
21
test/cdevCollection/add5.cc
Executable file
@@ -0,0 +1,21 @@
|
||||
#include <cdevCollection.h>
|
||||
|
||||
void main ( void )
|
||||
{
|
||||
/**************************************************************
|
||||
* Attach to the cdevCollection "brandNew" and add a NULL
|
||||
* terminated list of devices to it.
|
||||
**************************************************************/
|
||||
cdevCollection & brandNew = cdevCollection::attachRef("brandNew");
|
||||
brandNew.addRegexp("device?");
|
||||
|
||||
/**************************************************************
|
||||
* Use the getList method to obtain the array of names that are
|
||||
* currently stored in the cdevCollection and display them.
|
||||
* Note that the list (not the list items) msut be deleted by
|
||||
* the caller.
|
||||
**************************************************************/
|
||||
char ** list = brandNew.getList();
|
||||
for(char **s = list; *s!=NULL; s++) printf("%s\n", *s);
|
||||
delete list;
|
||||
}
|
||||
21
test/cdevCollection/attachCollection.cc
Executable file
21
test/cdevCollection/attachCollection.cc
Executable file
@@ -0,0 +1,21 @@
|
||||
#include <cdevCollection.h>
|
||||
|
||||
void main ( void )
|
||||
{
|
||||
/***************************************************************
|
||||
* Obtain a reference to a cdevCollection device named
|
||||
* "brandNew". Because this collection is not defined in the
|
||||
* CDEV DDL file, it will be created with no constituent
|
||||
* devices.
|
||||
***************************************************************/
|
||||
cdevCollection & brandNew = cdevCollection::attachRef("brandNew");
|
||||
|
||||
/***************************************************************
|
||||
* Obtain a reference to a cdevCollection device named
|
||||
* "cDevice1". This collection is defined in the CDEV DDL file
|
||||
* and will be populated with the devices: "device0", "device1",
|
||||
* and "device2".
|
||||
***************************************************************/
|
||||
cdevCollection * cDevice1 = cdevCollection::attachPtr("cDevice1");
|
||||
}
|
||||
|
||||
42
test/cdevCollection/collection.ddl
Executable file
42
test/cdevCollection/collection.ddl
Executable file
@@ -0,0 +1,42 @@
|
||||
service Sample
|
||||
{
|
||||
tags {server}
|
||||
}
|
||||
|
||||
class Samples
|
||||
{
|
||||
verbs {get, set, monitorOn, monitorOff}
|
||||
attributes
|
||||
{
|
||||
default Sample;
|
||||
servers Sample;
|
||||
attrib0 Sample;
|
||||
attrib1 Sample;
|
||||
attrib2 Sample;
|
||||
attrib3 Sample;
|
||||
attrib4 Sample;
|
||||
attrib5 Sample;
|
||||
attrib6 Sample;
|
||||
attrib7 Sample;
|
||||
attrib8 Sample;
|
||||
attrib9 Sample;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Samples :
|
||||
device0, device1, device2, device3, device4,
|
||||
device5, device6, device7, device8, device9
|
||||
;
|
||||
|
||||
collection cDevice1 :
|
||||
device0,
|
||||
device1,
|
||||
device2
|
||||
;
|
||||
|
||||
collection cDevice2 :
|
||||
device3
|
||||
device4
|
||||
device5
|
||||
;
|
||||
8
test/cdevCollection/detachCollection.cc
Executable file
8
test/cdevCollection/detachCollection.cc
Executable file
@@ -0,0 +1,8 @@
|
||||
#include <cdevCollection.h>
|
||||
|
||||
void main ( void )
|
||||
{
|
||||
cdevCollection & cDevice1 = cdevCollection::attachRef("cDevice1");
|
||||
cdevCollection::detach(cDevice1);
|
||||
}
|
||||
|
||||
18
test/cdevCollection/getList.cc
Executable file
18
test/cdevCollection/getList.cc
Executable file
@@ -0,0 +1,18 @@
|
||||
#include <cdevCollection.h>
|
||||
|
||||
void main ( void )
|
||||
{
|
||||
/**************************************************************
|
||||
* Attach to a cdevCollection device and then use the getList
|
||||
* method to obtain the array of names that are currently
|
||||
* stored in the cdevCollection and display them.
|
||||
*
|
||||
* Note that the list (not the list items) must be deleted by
|
||||
* the caller.
|
||||
**************************************************************/
|
||||
cdevCollection & cDevice1 = cdevCollection::attachRef("cDevice1");
|
||||
|
||||
char ** list = cDevice1.getList();
|
||||
for(char **s = list; *s!=NULL; s++) printf("%s\n", *s);
|
||||
delete list;
|
||||
}
|
||||
21
test/cdevCollection/remove1.cc
Executable file
21
test/cdevCollection/remove1.cc
Executable file
@@ -0,0 +1,21 @@
|
||||
#include <cdevCollection.h>
|
||||
|
||||
void main ( void )
|
||||
{
|
||||
/**************************************************************
|
||||
* Attach to a defined cdevCollection device and then remove
|
||||
* the cdevDevice "device0" from it.
|
||||
**************************************************************/
|
||||
cdevCollection & cDevice1 = cdevCollection::attachRef("cDevice1");
|
||||
cDevice1.remove("device0");
|
||||
|
||||
/**************************************************************
|
||||
* Use the getList method to obtain the array of names that are
|
||||
* currently stored in the cdevCollection and display them.
|
||||
* Note that the list (not the list items) msut be deleted by
|
||||
* the caller.
|
||||
**************************************************************/
|
||||
char ** list = cDevice1.getList();
|
||||
for(char **s = list; *s!=NULL; s++) printf("%s\n", *s);
|
||||
delete list;
|
||||
}
|
||||
21
test/cdevCollection/remove2.cc
Executable file
21
test/cdevCollection/remove2.cc
Executable file
@@ -0,0 +1,21 @@
|
||||
#include <cdevCollection.h>
|
||||
|
||||
void main ( void )
|
||||
{
|
||||
/**************************************************************
|
||||
* Attach to a defined cdevCollection device and then remove
|
||||
* two cdevDevices from it.
|
||||
**************************************************************/
|
||||
cdevCollection & cDevice1 = cdevCollection::attachRef("cDevice1");
|
||||
cDevice1.remove(2, "device0", "device2");
|
||||
|
||||
/**************************************************************
|
||||
* Use the getList method to obtain the array of names that are
|
||||
* currently stored in the cdevCollection and display them.
|
||||
* Note that the list (not the list items) msut be deleted by
|
||||
* the caller.
|
||||
**************************************************************/
|
||||
char ** list = cDevice1.getList();
|
||||
for(char **s = list; *s!=NULL; s++) printf("%s\n", *s);
|
||||
delete list;
|
||||
}
|
||||
23
test/cdevCollection/remove3.cc
Executable file
23
test/cdevCollection/remove3.cc
Executable file
@@ -0,0 +1,23 @@
|
||||
#include <cdevCollection.h>
|
||||
|
||||
char * devices[] = {"device0", "device2"};
|
||||
|
||||
void main ( void )
|
||||
{
|
||||
/**************************************************************
|
||||
* Attach to a defined cdevCollection device and then remove
|
||||
* two cdevDevices from it.
|
||||
**************************************************************/
|
||||
cdevCollection & cDevice1 = cdevCollection::attachRef("cDevice1");
|
||||
cDevice1.remove(2, devices);
|
||||
|
||||
/**************************************************************
|
||||
* Use the getList method to obtain the array of names that are
|
||||
* currently stored in the cdevCollection and display them.
|
||||
* Note that the list (not the list items) msut be deleted by
|
||||
* the caller.
|
||||
**************************************************************/
|
||||
char ** list = cDevice1.getList();
|
||||
for(char **s = list; *s!=NULL; s++) printf("%s\n", *s);
|
||||
delete list;
|
||||
}
|
||||
23
test/cdevCollection/remove4.cc
Executable file
23
test/cdevCollection/remove4.cc
Executable file
@@ -0,0 +1,23 @@
|
||||
#include <cdevCollection.h>
|
||||
|
||||
char * devices[] = {"device0", "device2", NULL};
|
||||
|
||||
void main ( void )
|
||||
{
|
||||
/**************************************************************
|
||||
* Attach to a defined cdevCollection device and then remove
|
||||
* a NULL terminated list of devices from it.
|
||||
**************************************************************/
|
||||
cdevCollection & cDevice1 = cdevCollection::attachRef("cDevice1");
|
||||
cDevice1.remove(devices);
|
||||
|
||||
/**************************************************************
|
||||
* Use the getList method to obtain the array of names that are
|
||||
* currently stored in the cdevCollection and display them.
|
||||
* Note that the list (not the list items) msut be deleted by
|
||||
* the caller.
|
||||
**************************************************************/
|
||||
char ** list = cDevice1.getList();
|
||||
for(char **s = list; *s!=NULL; s++) printf("%s\n", *s);
|
||||
delete list;
|
||||
}
|
||||
21
test/cdevCollection/remove5.cc
Executable file
21
test/cdevCollection/remove5.cc
Executable file
@@ -0,0 +1,21 @@
|
||||
#include <cdevCollection.h>
|
||||
|
||||
void main ( void )
|
||||
{
|
||||
/**************************************************************
|
||||
* Attach to a defined cdevCollection device and then remove
|
||||
* all devices that match the specified regular expression.
|
||||
**************************************************************/
|
||||
cdevCollection & cDevice1 = cdevCollection::attachRef("cDevice1");
|
||||
cDevice1.removeRegexp("device?");
|
||||
|
||||
/**************************************************************
|
||||
* Use the getList method to obtain the array of names that are
|
||||
* currently stored in the cdevCollection and display them.
|
||||
* Note that the list (not the list items) msut be deleted by
|
||||
* the caller.
|
||||
**************************************************************/
|
||||
char ** list = cDevice1.getList();
|
||||
for(char **s = list; *s!=NULL; s++) printf("%s\n", *s);
|
||||
delete list;
|
||||
}
|
||||
Reference in New Issue
Block a user