This is Unofficial EPICS BASE Doxygen Site
epics::pvDatabase::AddRecord Class Reference

Add another record in the same database. More...

#include "addRecord.h"

+ Inheritance diagram for epics::pvDatabase::AddRecord:
+ Collaboration diagram for epics::pvDatabase::AddRecord:

Public Member Functions

 POINTER_DEFINITIONS (AddRecord)
 
virtual bool init ()
 
virtual void process ()
 Add the record specified by recordName. More...
 
- Public Member Functions inherited from epics::pvDatabase::PVRecord
 POINTER_DEFINITIONS (PVRecord)
 
virtual ~PVRecord ()
 
virtual void start ()
 Optional method for derived class. More...
 
virtual void destroy ()
 DEPRECATED. More...
 
virtual void remove ()
 remove record from database. More...
 
virtual epics::pvAccess::RPCServiceAsync::shared_pointer getService (epics::pvData::PVStructurePtr const &pvRequest)
 Optional method for derived class. More...
 
std::string getRecordName () const
 Get the name of the record. More...
 
PVRecordStructurePtr getPVRecordStructure () const
 Get the top level PVRecordStructure. More...
 
epics::pvData::PVStructurePtr getPVStructure () const
 Get the top level PVStructure. More...
 
PVRecordFieldPtr findPVRecordField (epics::pvData::PVFieldPtr const &pvField)
 Find the PVRecordField for the PVField. More...
 
void lock ()
 Lock the record. More...
 
void unlock ()
 Unlock the record. More...
 
bool tryLock ()
 Try to lock the record. More...
 
void lockOtherRecord (PVRecordPtr const &otherRecord)
 Lock another record. More...
 
bool addPVRecordClient (PVRecordClientPtr const &pvRecordClient)
 Add a client that wants to access the record. More...
 
bool addListener (PVListenerPtr const &pvListener, epics::pvCopy::PVCopyPtr const &pvCopy)
 Add a PVListener. More...
 
void nextMasterPVField (epics::pvData::PVFieldPtr const &pvField)
 PVCopyTraverseMasterCallback method. More...
 
bool removeListener (PVListenerPtr const &pvListener, epics::pvCopy::PVCopyPtr const &pvCopy)
 Remove a listener. More...
 
void beginGroupPut ()
 Begins a group of puts. More...
 
void endGroupPut ()
 Ends a group of puts. More...
 
int getTraceLevel ()
 get trace level (0,1,2) means (nothing,lifetime,process) More...
 
void setTraceLevel (int level)
 set trace level (0,1,2) means (nothing,lifetime,process) More...
 
- Public Member Functions inherited from epics::pvCopy::PVCopyTraverseMasterCallback
 POINTER_DEFINITIONS (PVCopyTraverseMasterCallback)
 
virtual ~PVCopyTraverseMasterCallback ()
 

Static Public Member Functions

static AddRecordPtr create (std::string const &recordName)
 
- Static Public Member Functions inherited from epics::pvDatabase::PVRecord
static PVRecordPtr create (std::string const &recordName, epics::pvData::PVStructurePtr const &pvStructure)
 Creates a soft record. More...
 

Additional Inherited Members

- Protected Member Functions inherited from epics::pvDatabase::PVRecord
 PVRecord (std::string const &recordName, epics::pvData::PVStructurePtr const &pvStructure)
 Constructor. More...
 
void initPVRecord ()
 Initializes the base class. More...
 

Detailed Description

Add another record in the same database.

A record to add another record It is meant to be used via a channelPutGet request. The argument has one field: recordName. The result has a field named status.

Definition at line 32 of file addRecord.h.

Member Function Documentation

AddRecordPtr epics::pvDatabase::AddRecord::create ( std::string const &  recordName)
static

Factory methods to create AddRecord.

Parameters
recordNameThe name for the AddRecord.
Returns
A shared pointer to AddRecord..

Definition at line 42 of file addRecord.cpp.

44 {
45  FieldCreatePtr fieldCreate = getFieldCreate();
46  PVDataCreatePtr pvDataCreate = getPVDataCreate();
47  StructureConstPtr topStructure = fieldCreate->createFieldBuilder()->
48  addNestedStructure("argument")->
49  add("recordName",pvString)->
50  addNestedUnion("union") ->
51  endNested()->
52  endNested()->
53  addNestedStructure("result") ->
54  add("status",pvString) ->
55  endNested()->
56  createStructure();
57  PVStructurePtr pvStructure = pvDataCreate->createPVStructure(topStructure);
58  AddRecordPtr pvRecord(
59  new AddRecord(recordName,pvStructure));
60  if(!pvRecord->init()) pvRecord.reset();
61  return pvRecord;
62 }
std::tr1::shared_ptr< const Structure > StructureConstPtr
Definition: pvIntrospect.h:162
std::tr1::shared_ptr< AddRecord > AddRecordPtr
Definition: addRecord.h:21
std::tr1::shared_ptr< PVDataCreate > PVDataCreatePtr
Definition: pvData.h:124
FORCE_INLINE const FieldCreatePtr & getFieldCreate()
std::tr1::shared_ptr< PVStructure > PVStructurePtr
Definition: pvData.h:87
std::tr1::shared_ptr< FieldCreate > FieldCreatePtr
FORCE_INLINE const PVDataCreatePtr & getPVDataCreate()
Definition: pvData.h:1648
bool epics::pvDatabase::AddRecord::init ( )
virtual

standard init method required by PVRecord

Returns
true unless record name already exists.

Reimplemented from epics::pvDatabase::PVRecord.

Definition at line 71 of file addRecord.cpp.

72 {
73  initPVRecord();
74  PVStructurePtr pvStructure = getPVStructure();
75  pvRecordName = pvStructure->getSubField<PVString>("argument.recordName");
76  if(!pvRecordName) return false;
77  pvResult = pvStructure->getSubField<PVString>("result.status");
78  if(!pvResult) return false;
79  return true;
80 }
epics::pvData::PVStructurePtr getPVStructure() const
Get the top level PVStructure.
Definition: pvDatabase.h:141
PVString is special case, since it implements SerializableArray.
Definition: pvData.h:521
std::tr1::shared_ptr< PVStructure > PVStructurePtr
Definition: pvData.h:87
void initPVRecord()
Initializes the base class.
Definition: pvRecord.cpp:110
epics::pvDatabase::AddRecord::POINTER_DEFINITIONS ( AddRecord  )
void epics::pvDatabase::AddRecord::process ( )
virtual

Add the record specified by recordName.

Reimplemented from epics::pvDatabase::PVRecord.

Definition at line 82 of file addRecord.cpp.

83 {
84  PVDataCreatePtr pvDataCreate = getPVDataCreate();
85  string name = pvRecordName->get();
86  PVRecordPtr pvRecord = PVDatabase::getMaster()->findRecord(name);
87  if(pvRecord) {
88  pvResult->put(name + " already exists");
89  return;
90  }
91  PVUnionPtr pvUnion = getPVStructure()->getSubField<PVUnion>("argument.union");
92  if(!pvUnion) {
93  pvResult->put(name + " argument.union is NULL");
94  return;
95  }
96  PVFieldPtr pvField(pvUnion->get());
97  if(!pvField) {
98  pvResult->put(name + " union has no value");
99  return;
100  }
101  if(pvField->getField()->getType()!=epics::pvData::structure) {
102  pvResult->put(name + " union most be a structure");
103  return;
104  }
105  StructureConstPtr st = static_pointer_cast<const Structure>(pvField->getField());
106  PVStructurePtr pvStructure = pvDataCreate->createPVStructure(st);
107  PVRecordPtr pvRec = PVRecord::create(name,pvStructure);
108  bool result = PVDatabase::getMaster()->addRecord(pvRec);
109  if(result) {
110  pvResult->put("success");
111  } else {
112  pvResult->put("failure");
113  }
114 }
pvac::PutEvent result
Definition: clientSync.cpp:117
epics::pvData::PVStructurePtr getPVStructure() const
Get the top level PVStructure.
Definition: pvDatabase.h:141
shared_ptr< T > static_pointer_cast(shared_ptr< U > const &r) BOOST_NOEXCEPT
Definition: shared_ptr.hpp:788
std::tr1::shared_ptr< const Structure > StructureConstPtr
Definition: pvIntrospect.h:162
std::tr1::shared_ptr< PVDataCreate > PVDataCreatePtr
Definition: pvData.h:124
std::tr1::shared_ptr< PVUnion > PVUnionPtr
Definition: pvData.h:107
This class implements introspection object for a structure.
Definition: pvIntrospect.h:697
PVUnion has a single subfield.
Definition: pvData.h:940
static PVDatabasePtr getMaster()
Get the master database.
Definition: pvDatabase.cpp:38
std::tr1::shared_ptr< PVRecord > PVRecordPtr
Definition: pvDatabase.h:21
std::tr1::shared_ptr< PVStructure > PVStructurePtr
Definition: pvData.h:87
static PVRecordPtr create(std::string const &recordName, epics::pvData::PVStructurePtr const &pvStructure)
Creates a soft record.
Definition: pvRecord.cpp:38
std::tr1::shared_ptr< PVField > PVFieldPtr
Definition: pvData.h:66
FORCE_INLINE const PVDataCreatePtr & getPVDataCreate()
Definition: pvData.h:1648

The documentation for this class was generated from the following files: