All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
ConstantEventMap Class Reference

#include <event-map.h>

Inheritance diagram for ConstantEventMap:
Collaboration diagram for ConstantEventMap:

Public Member Functions

virtual bool Map (const EventType &event, EventAnswerType *ans) const
 
virtual void MultiMap (const EventType &, std::vector< EventAnswerType > *ans) const
 
virtual void GetChildren (std::vector< EventMap * > *out) const
 
virtual EventMapCopy (const std::vector< EventMap * > &new_leaves) const
 
virtual EventMapMapValues (const unordered_set< EventKeyType > &keys_to_map, const unordered_map< EventValueType, EventValueType > &value_map) const
 
virtual EventMapPrune () const
 
 ConstantEventMap (EventAnswerType answer)
 
virtual void Write (std::ostream &os, bool binary)
 Write to stream. More...
 
- Public Member Functions inherited from EventMap
EventMapCopy () const
 
virtual EventAnswerType MaxResult () const
 
virtual ~EventMap ()
 

Static Public Member Functions

static ConstantEventMapRead (std::istream &is, bool binary)
 
- Static Public Member Functions inherited from EventMap
static void Check (const EventType &event)
 
static bool Lookup (const EventType &event, EventKeyType key, EventValueType *ans)
 
static void Write (std::ostream &os, bool binary, EventMap *emap)
 a Write function that takes care of NULL pointers. More...
 
static EventMapRead (std::istream &is, bool binary)
 a Read function that reads an arbitrary EventMap; also works for NULL pointers. More...
 

Private Member Functions

 KALDI_DISALLOW_COPY_AND_ASSIGN (ConstantEventMap)
 

Private Attributes

EventAnswerType answer_
 

Detailed Description

Definition at line 166 of file event-map.h.

Constructor & Destructor Documentation

ConstantEventMap ( EventAnswerType  answer)
inlineexplicit

Member Function Documentation

virtual EventMap* Copy ( const std::vector< EventMap * > &  new_leaves) const
inlinevirtual

Implements EventMap.

Definition at line 180 of file event-map.h.

References ConstantEventMap::answer_, and ConstantEventMap::ConstantEventMap().

180  {
181  if (answer_ < 0 || answer_ >= (EventAnswerType)new_leaves.size() ||
182  new_leaves[answer_] == NULL)
183  return new ConstantEventMap(answer_);
184  else return new_leaves[answer_]->Copy();
185  }
ConstantEventMap(EventAnswerType answer)
Definition: event-map.h:197
EventAnswerType answer_
Definition: event-map.h:202
int32 EventAnswerType
As far as the event-map code itself is concerned, things of type EventAnswerType may take any value e...
Definition: event-map.h:56
virtual void GetChildren ( std::vector< EventMap * > *  out) const
inlinevirtual

Implements EventMap.

Definition at line 178 of file event-map.h.

178 { out->clear(); }
KALDI_DISALLOW_COPY_AND_ASSIGN ( ConstantEventMap  )
private
virtual bool Map ( const EventType event,
EventAnswerType ans 
) const
inlinevirtual

Implements EventMap.

Definition at line 168 of file event-map.h.

References ConstantEventMap::answer_.

168  {
169  *ans = answer_;
170  return true;
171  }
EventAnswerType answer_
Definition: event-map.h:202
virtual EventMap* MapValues ( const unordered_set< EventKeyType > &  keys_to_map,
const unordered_map< EventValueType, EventValueType > &  value_map 
) const
inlinevirtual

Implements EventMap.

Definition at line 187 of file event-map.h.

References ConstantEventMap::answer_, and ConstantEventMap::ConstantEventMap().

189  {
190  return new ConstantEventMap(answer_);
191  }
ConstantEventMap(EventAnswerType answer)
Definition: event-map.h:197
EventAnswerType answer_
Definition: event-map.h:202
virtual void MultiMap ( const EventType ,
std::vector< EventAnswerType > *  ans 
) const
inlinevirtual

Implements EventMap.

Definition at line 173 of file event-map.h.

References ConstantEventMap::answer_.

174  {
175  ans->push_back(answer_);
176  }
EventAnswerType answer_
Definition: event-map.h:202
virtual EventMap* Prune ( ) const
inlinevirtual

Implements EventMap.

Definition at line 193 of file event-map.h.

References ConstantEventMap::answer_, and ConstantEventMap::ConstantEventMap().

193  {
194  return (answer_ == -1 ? NULL : new ConstantEventMap(answer_));
195  }
ConstantEventMap(EventAnswerType answer)
Definition: event-map.h:197
EventAnswerType answer_
Definition: event-map.h:202
ConstantEventMap * Read ( std::istream &  is,
bool  binary 
)
static

Definition at line 64 of file event-map.cc.

References ConstantEventMap::ConstantEventMap(), kaldi::ExpectToken(), and kaldi::ReadBasicType().

Referenced by EventMap::Read().

64  {
65  ExpectToken(is, binary, "CE");
66  EventAnswerType answer;
67  ReadBasicType(is, binary, &answer);
68  return new ConstantEventMap(answer);
69 }
ConstantEventMap(EventAnswerType answer)
Definition: event-map.h:197
void ReadBasicType(std::istream &is, bool binary, T *t)
ReadBasicType is the name of the read function for bool, integer types, and floating-point types...
Definition: io-funcs-inl.h:55
void ExpectToken(std::istream &is, bool binary, const char *token)
ExpectToken tries to read in the given token, and throws an exception on failure. ...
Definition: io-funcs.cc:188
int32 EventAnswerType
As far as the event-map code itself is concerned, things of type EventAnswerType may take any value e...
Definition: event-map.h:56
void Write ( std::ostream &  os,
bool  binary 
)
virtual

Write to stream.

Implements EventMap.

Definition at line 55 of file event-map.cc.

References ConstantEventMap::answer_, KALDI_ERR, kaldi::WriteBasicType(), and kaldi::WriteToken().

55  {
56  WriteToken(os, binary, "CE");
57  WriteBasicType(os, binary, answer_);
58  if (os.fail()) {
59  KALDI_ERR << "ConstantEventMap::Write(), could not write to stream.";
60  }
61 }
EventAnswerType answer_
Definition: event-map.h:202
#define KALDI_ERR
Definition: kaldi-error.h:127
void WriteToken(std::ostream &os, bool binary, const char *token)
The WriteToken functions are for writing nonempty sequences of non-space characters.
Definition: io-funcs.cc:134
void WriteBasicType(std::ostream &os, bool binary, T t)
WriteBasicType is the name of the write function for bool, integer types, and floating-point types...
Definition: io-funcs-inl.h:34

Member Data Documentation


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