This is Unofficial EPICS BASE Doxygen Site
StandardPVField.cpp
Go to the documentation of this file.
1 /* StandardPVField.cpp */
2 /*
3  * Copyright information and license terms for this software can be
4  * found in the file LICENSE that is included with the distribution
5  */
9 #include <string>
10 #include <stdexcept>
11 
12 #include <epicsMutex.h>
13 
14 #define epicsExportSharedSymbols
15 #include <pv/lock.h>
16 #include <pv/pvIntrospect.h>
17 #include <pv/pvData.h>
18 #include <pv/standardField.h>
19 #include <pv/standardPVField.h>
20 
21 using std::string;
22 
23 namespace epics { namespace pvData {
24 
25 StandardPVField::StandardPVField()
26 : standardField(getStandardField()),
27  fieldCreate(getFieldCreate()),
28  pvDataCreate(getPVDataCreate()),
29  notImplemented("not implemented")
30 {}
31 
32 StandardPVField::~StandardPVField(){}
33 
34 PVStructurePtr StandardPVField::scalar(
35  ScalarType type,string const & properties)
36 {
37  StructureConstPtr field = standardField->scalar(type,properties);
38  PVStructurePtr pvStructure = pvDataCreate->createPVStructure(field);
39  return pvStructure;
40 }
41 
42 PVStructurePtr StandardPVField::scalarArray(
43  ScalarType elementType, string const & properties)
44 {
45  StructureConstPtr field = standardField->scalarArray(elementType,properties);
46  PVStructurePtr pvStructure = pvDataCreate->createPVStructure(field);
47  return pvStructure;
48 }
49 
50 PVStructurePtr StandardPVField::structureArray(
51  StructureConstPtr const & structure,string const & properties)
52 {
53  StructureConstPtr field = standardField->structureArray(structure,properties);
54  PVStructurePtr pvStructure = pvDataCreate->createPVStructure(field);
55  return pvStructure;
56 }
57 
58 PVStructurePtr StandardPVField::unionArray(
59  UnionConstPtr const & punion,string const & properties)
60 {
61  StructureConstPtr field = standardField->unionArray(punion,properties);
62  PVStructurePtr pvStructure = pvDataCreate->createPVStructure(field);
63  return pvStructure;
64 }
65 
66 PVStructurePtr StandardPVField::enumerated(StringArray const &choices)
67 {
68  StructureConstPtr field = standardField->enumerated();
69  PVStructurePtr pvStructure = pvDataCreate->createPVStructure(field);
70  PVStringArray::svector cdata(choices.size());
71  std::copy(choices.begin(), choices.end(), cdata.begin());
72  pvStructure->getSubFieldT<PVStringArray>("choices")->replace(freeze(cdata));
73  return pvStructure;
74 }
75 
76 PVStructurePtr StandardPVField::enumerated(
77  StringArray const &choices,string const & properties)
78 {
79  StructureConstPtr field = standardField->enumerated(properties);
80  PVStructurePtr pvStructure = pvDataCreate->createPVStructure(field);
81  PVStringArray::svector cdata(choices.size());
82  std::copy(choices.begin(), choices.end(), cdata.begin());
83  pvStructure->getSubFieldT<PVStringArray>("value.choices")->replace(freeze(cdata));
84  return pvStructure;
85 }
86 
88 {
89  static StandardPVFieldPtr standardPVField;
90  static Mutex mutex;
91  Lock xx(mutex);
92 
93  if(standardPVField.get()==NULL) {
94  standardPVField= StandardPVFieldPtr(new StandardPVField());
95  }
96  return standardPVField;
97 }
98 
101 }
102 
103 }}
::epics::pvData::shared_vector< T > svector
Definition: pvData.h:1184
StandardPVFieldPtr getStandardPVField()
pvd::StructureConstPtr type
TODO only here because of the Lockable.
Definition: ntaggregate.cpp:16
std::tr1::shared_ptr< const Structure > StructureConstPtr
Definition: pvIntrospect.h:162
#define NULL
Definition: catime.c:38
void copy(PVValueArray< T > &pvFrom, size_t fromOffset, size_t fromStride, PVValueArray< T > &pvTo, size_t toOffset, size_t toStride, size_t count)
Copy a subarray from one scalar array to another.
std::tr1::shared_ptr< StandardPVField > StandardPVFieldPtr
FORCE_INLINE const StandardFieldPtr & getStandardField()
std::tr1::shared_ptr< const Union > UnionConstPtr
Definition: pvIntrospect.h:170
epicsMutex mutex
Definition: pvAccess.cpp:71
APIs for the epicsMutex mutual exclusion semaphore.
FORCE_INLINE const FieldCreatePtr & getFieldCreate()
std::tr1::shared_ptr< PVStructure > PVStructurePtr
Definition: pvData.h:87
std::vector< std::string > StringArray
Definition: pvType.h:110
PVValueArray< std::string > PVStringArray
Definition: pvData.h:1463
epicsMutex Mutex
Definition: lock.h:28
FORCE_INLINE const PVDataCreatePtr & getPVDataCreate()
Definition: pvData.h:1648