Skip to content

Commit

Permalink
make evioDictEntry's setFormat and setDescription private
Browse files Browse the repository at this point in the history
  • Loading branch information
carltimmer committed Nov 18, 2016
1 parent 4f4d3af commit 31b61e5
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 36 deletions.
19 changes: 19 additions & 0 deletions src/libsrc++/evioDictEntry.cc
Original file line number Diff line number Diff line change
Expand Up @@ -235,5 +235,24 @@ bool evioDictEntry::inRange(uint16_t tagArg) {



//-----------------------------------------------------------------------


/**
* Given a string data type, return the equivalent DataType enum.
*
* @parm type data type string of "unknown32", "uint32", ... "bank", "segment".
* @return DataType enum equivalent of arg.
*/
DataType evioDictEntry::getDataType(const char *type) {
for (int i=0; i < 18; i++) {
if (strcasecmp(type, DataTypeNames[i]) == 0) {
return DataTypes[i];
}
}
return EVIO_UNKNOWN32;
}




21 changes: 12 additions & 9 deletions src/libsrc++/evioDictEntry.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
#include <string>
#include <iostream>
#include "evioException.hxx"
#include "evioDictionary.hxx"

namespace evio {

using namespace std;



/** An entry in the dictionary can be either a tag/num pair, a tag only, or a range of tags. */
enum DictEntryType {TAG_NUM, TAG_ONLY, TAG_RANGE};

Expand Down Expand Up @@ -69,6 +69,10 @@ namespace evio {
class evioDictEntry {

public:
// These methods need to call setFormat and setDescription which should be private
friend void evioDictionary::startElementHandler(void *userData, const char *xmlname, const char **atts);
friend void evioDictionary::charDataHandler(void *userData, const char *s, int len);

evioDictEntry();
evioDictEntry(uint16_t tag);
evioDictEntry(uint16_t tag, uint8_t num, uint16_t tagEnd);
Expand All @@ -95,14 +99,8 @@ namespace evio {
bool isNumUndefined(void) const;
DataType getType(void) const;
DictEntryType getEntryType(void) const;

string getFormat(void) const;
void setFormat(const string &format);
void setFormat(const char *format);

string getDescription(void) const;
void setDescription(const string &description);
void setDescription(const char *description);

// Parent entry methods

Expand All @@ -113,12 +111,18 @@ namespace evio {

// General

static DataType getDataType(const char *type);
string toString(void) const throw(evioException);
bool inRange(uint16_t tagArg);


private:
void setFormat(const string &format);
void setFormat(const char *format);

void setDescription(const string &description);
void setDescription(const char *description);

private:
/** Tag value or low end of a tag range of an evio container. */
uint16_t tag;

Expand Down Expand Up @@ -167,7 +171,6 @@ namespace evio {
uint8_t parentNum;



public:
// Redefine == for this class
inline bool operator == (const evioDictEntry & tn) const
Expand Down
24 changes: 3 additions & 21 deletions src/libsrc++/evioDictionary.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/


#include "evioDictEntry.hxx"
#include "evioDictionary.hxx"
#include <fstream>
#include <cstring>
Expand Down Expand Up @@ -449,7 +450,7 @@ void evioDictionary::startElementHandler(void *userData, const char *xmlname, co
numIsDefined = true;
}
else if (strcasecmp(atts[i], "type")==0) {
type = getDataType(atts[i+1]);
type = evioDictEntry::getDataType(atts[i+1]);
typeIsDefined = true;
cout << "type = " << type << endl;
}
Expand Down Expand Up @@ -705,25 +706,6 @@ void evioDictionary::endElementHandler(void *userData, const char *xmlname) {
//-----------------------------------------------------------------------


/**
* Given a string data type, return the equivalent DataType enum.
*
* @parm type data type string of "unknown32", "uint32", ... "bank", "segment".
* @return DataType enum equivalent of arg.
*/
DataType evioDictionary::getDataType(const char *type) {
for (int i=0; i < 18; i++) {
if (strcasecmp(type, DataTypeNames[i]) == 0) {
return DataTypes[i];
}
}
return EVIO_UNKNOWN32;
}


//-----------------------------------------------------------------------


/**
* Gets the dictionary entry (evioDictEntry) for a given name.
*
Expand Down Expand Up @@ -753,7 +735,7 @@ evioDictEntry evioDictionary::getEntry(const string &name) const throw(evioExcep
* @return name associated with entry
* @throws evioException if entry not found
*/
string evioDictionary::getName(evioDictEntry entry) const throw(evioException) {
string evioDictionary::getName(evioDictEntry &entry) const throw(evioException) {
// First, see if there is an exact match in map which contains all entries
map<evioDictEntry, string>::const_iterator iter = getNameMap.find(entry);
if (iter != getNameMap.end()) {
Expand Down
14 changes: 8 additions & 6 deletions src/libsrc++/evioDictionary.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
#define _evioDictionary_hxx


#include "evioDictEntry.hxx"
//#include "evioDictEntry.hxx"
#include "evioTypedefs.hxx"
#include "evioException.hxx"

Expand All @@ -55,7 +55,7 @@ using namespace evio;
const string dictEntryTag = "dictentry";
const string oldDictEntryTag = "xmldumpdictdntry";


class evioDictEntry;

/**
* This class parses XML dictionary string and contains maps for looking up dictionary information.
Expand All @@ -72,7 +72,7 @@ public:
public:
bool parseDictionary(const string &dictionaryXML);
evioDictEntry getEntry(const string &name) const throw(evioException);
string getName(evioDictEntry entry) const throw(evioException);
string getName(evioDictEntry &entry) const throw(evioException);
string getName(uint16_t tag, uint8_t num, uint16_t tagEnd=0, bool haveParent=false,
uint16_t parentTag=0, uint8_t parentNum=0, uint16_t parentTagEnd=0) const throw(evioException);

Expand All @@ -81,14 +81,16 @@ public:
string getSeparator(void) const;
string toString(void) const throw(evioException);

static DataType getDataType(const char *type) ;


private:
public:
// It's necessary to make these public so they can be friend methods to evioDictEntry,
// which in turn allows them access to private methods that set format and description.
static void startElementHandler(void *userData, const char *xmlname, const char **atts);
static void endElementHandler(void *userData, const char *xmlname);
static void charDataHandler(void *userData, const char *s, int len);


private:
/** String containing the xml dictionary. */
string dictionaryXML;
/** Separator to use between elements of hierarchical names. Currently a period. */
Expand Down

0 comments on commit 31b61e5

Please sign in to comment.