Commit 965fcf44 authored by Christopher Reis's avatar Christopher Reis

Initial Template Commit

parents
# Copyright 2007-2016 United States Government as represented by the
# Administrator of The National Aeronautics and Space Administration.
# No copyright is claimed in the United States under Title 17, U.S. Code.
# All Rights Reserved.
# Makefile - middleware wrapper template
GMSEC_HOME = ../..
include $(GMSEC_HOME)/config/$(GMSEC_PLATFORM)
LIBROOTNAME = gmsec_void
TARGET = lib$(LIBROOTNAME).$(SHLIB_EXT)
OBJDIR = ./src
LOCAL_DEFS = -DGMSEC_LIBROOTNAME=$(LIBROOTNAME)
LOCAL_INCS = \
-Iinclude
CXXFLAGS += $(LOCAL_DEFS) $(LOCAL_INCS)
LIBDIRS =
LIBS =
#
SRCDIR = src
OBJECTS = \
$(OBJDIR)/gmsec_void.o \
$(OBJDIR)/VoidConnection.o \
$(OBJDIR)/VoidMessage.o
# default: clean library
default: library
library: $(BINDIR)/$(TARGET)
clean:
$(RM) $(OBJECTS)
$(RM) $(BINDIR)/$(TARGET)
$(BINDIR)/$(TARGET): $(OBJECTS)
$(DLINK) $(BASE_LDFLAGS) $(OBJECTS) $(LIBDIRS) $(LIBS) -o $@
$(OBJDIR)/%.o: $(SRCDIR)/%.cpp
$(CXX) -c $(CXXFLAGS) $< -o $@
/*
* Copyright 2007-2016 United States Government as represented by the
* Administrator of The National Aeronautics and Space Administration.
* No copyright is claimed in the United States under Title 17, U.S. Code.
* All Rights Reserved.
*/
/* @file VoidConnection.h
* This file provides a template for implementing a middleware wrapper.
*/
#ifndef _VoidConnection_h_
#define _VoidConnection_h_
#include <gmsec_void.h>
#include <gmsec/internal/BaseConnection.h>
#include <VoidMessage.h>
/** @class VoidConnection
* This class provides a sample (dummy) implementation of the
* BaseConnection abstract class.
*/
class GMSEC_VOID_API VoidConnection
: public gmsec::internal::BaseConnection
{
private:
public:
/** @fn VoidConnection(gmsec::Config *cfg)
* Standard constructor that requires a config
*/
VoidConnection(gmsec::Config *cfg);
virtual ~VoidConnection();
/** @fn CloneMessage( gmsec::Message *in, gmsec::Message *&out )
* This function copies a message without knowing what type it is
*/
virtual gmsec::Status CALL_TYPE CloneMessage(gmsec::Message *in, gmsec::Message *&out);
/** @fn GetLibraryVersion()
* Retrieve the version of the underlying middleware libraries
*/
virtual const char * CALL_TYPE GetLibraryVersion();
/** @fn GetLibraryRootName()
* Retrieve the root library name
*/
virtual const char * CALL_TYPE GetLibraryRootName()
{
return "gmsec_void";
}
/** @fn mwConnect()
* @brief Establish connection to the server.
*/
virtual gmsec::Status CALL_TYPE mwConnect();
/** @fn mwDisconnect()
* @brief End connection to the server.
*/
virtual gmsec::Status CALL_TYPE mwDisconnect();
/** @fn mwSubscribe(const char *subject, const gmsec::Config &config)
* @brief Subscribe to a subject without a callback
*/
virtual gmsec::Status CALL_TYPE mwSubscribe(const char *subject, const gmsec::Config &config);
/** @fn mwUnSubscribe(const char *subject)
* @brief Unsubscribe from a subject
*/
virtual gmsec::Status CALL_TYPE mwUnSubscribe(const char *subject);
/** @fn mwCreateMessage(const char *subject, GMSEC_MSG_KIND msgKind, gmsec::Message *&msg)
* @brief Create a middleware specific message.
*/
virtual gmsec::Status CALL_TYPE mwCreateMessage(const char *subject, GMSEC_MSG_KIND msgKind, gmsec::Message *&msg);
/** @fn DestroyMessage(gmsec::Message *msg)
* destroy an void message
*/
virtual gmsec::Status CALL_TYPE DestroyMessage(gmsec::Message *msg);
/** @fn mwPublish(gmsec::Message *msg, const gmsec::Config &config)
* @brief Send the message to the middleware.
*/
virtual gmsec::Status CALL_TYPE mwPublish(gmsec::Message *msg, const gmsec::Config &config);
/** @fn mwRequest(gmsec::Message *request, long timeout, gmsec::Message *&reply)
* @brief Send a request message to the middleware.
*/
virtual gmsec::Status CALL_TYPE mwRequest(gmsec::Message *request, std::string &id);
/** @fn mwReply(gmsec::Message *request,gmsec::Message *reply)
* @brief Send a reply message to the middleware.
*/
virtual gmsec::Status CALL_TYPE mwReply(gmsec::Message *request,gmsec::Message *reply);
/** @fn GetNextMsg(gmsec::Message *&msg, long timeout)
* pull the next message off the inbound queue
*/
virtual gmsec::Status CALL_TYPE mwGetNextMsg(gmsec::Message *&msg, long timeout);
};
#endif // VoidConnection_h
/*
* Copyright 2007-2016 United States Government as represented by the
* Administrator of The National Aeronautics and Space Administration.
* No copyright is claimed in the United States under Title 17, U.S. Code.
* All Rights Reserved.
*/
/* @file VoidMessage.h
* This file provides a template for implementing a middleware wrapper.
*/
#ifndef _VoidMessage_h_
#define _VoidMessage_h_
#include <gmsec_void.h>
#include <gmsec/internal/SimpleMessage.h>
/** @class VoidMessage
* This class implements the Message abstract base class to support
* Void middleware.
*/
class GMSEC_VOID_API VoidMessage
: public gmsec::internal::SimpleMessage
{
public:
/** @fn VoidMessage(subject, type)
* Standard constructor that takes a void message pointer
*/
VoidMessage();
virtual ~VoidMessage();
/** @fn getCMessagePtr()
* Access to the unlying void native message pointer.
*/
// CMessage * CALL_TYPE getCMessagePtr() { return NULL; }
/** @fn GetLibraryRootName()
* Retrieve the root library name.
*/
virtual const char * CALL_TYPE GetLibraryRootName()
{
return "gmsec_void";
}
#ifdef SUBCLASS_BASEMESSAGE
/** @fn ProcessConfigValue(const char *name, const char *value)
* Support function to add configuration value support for
* this particular middleware.
*/
virtual bool CALL_TYPE ProcessConfigValue(const char *name, const char *value);
/** @fn isValid()
* Check to see if this message has a valid native pointer
*/
virtual bool CALL_TYPE isValid();
/** @fn SetKind(GMSEC_MSG_KIND kind)
* Set the message kind (PUBLISH,REQUEST,REPLY)
*/
virtual gmsec::Status CALL_TYPE mwSetKind(GMSEC_MSG_KIND kind);
/** @fn GetKind(GMSEC_MSG_KIND &kind)
* Get the message kind (PUBLISH,REQUEST,REPLY)
*/
virtual gmsec::Status CALL_TYPE GetKind(GMSEC_MSG_KIND &kind);
/** @fn SetSubject(const char *subject)
* Set the message subject
*/
virtual gmsec::Status CALL_TYPE mwSetSubject(const char *subject);
/** @fn GetSubject(const char *&subject)
* Get the message subject
*/
virtual gmsec::Status CALL_TYPE GetSubject(const char *&subject);
/** @fn ClearFields()
* Clear all fields.
*/
virtual gmsec::Status CALL_TYPE ClearFields();
/** @fn AddField(gmsec::Field &field)
* Add a field to this message. This will overwrite an existing field
* of the same name.
*/
virtual gmsec::Status CALL_TYPE AddField(gmsec::Field &field);
/** @fn ClearField(const char *name)
* Clear this named field.
*/
virtual gmsec::Status CALL_TYPE ClearField(const char *name);
/** @fn GetField(const char *name, gmsec::Field &field)
* Get a field by name if available.
*/
virtual gmsec::Status CALL_TYPE GetField(const char *name, gmsec::Field &field);
/** @fn GetFieldCount(long &count)
* Get the number of available fields
*/
virtual gmsec::Status CALL_TYPE GetFieldCount(long &count);
/** @fn GetMSGSize(unsigned long &size)
* Get the physical message size
*/
virtual gmsec::Status CALL_TYPE GetMSGSize(unsigned long &size);
/** @fn GetFirstField(gmsec::Field &field)
* Iteration of fields, this will get the first field and reset the
* internal iteration to the first field.
*/
virtual gmsec::Status CALL_TYPE GetFirstField(gmsec::Field &field);
/** @fn GetNextField(gmsec::Field &field)
* Iteration of fields, this will get the next field and set the
* internal iteration to the next field.
*/
virtual gmsec::Status CALL_TYPE GetNextField(gmsec::Field &field);
#endif /* SUBCLASS_BASEMESSAGE */
};
#endif // VoidMessage_h
/*
* Copyright 2007-2016 United States Government as represented by the
* Administrator of The National Aeronautics and Space Administration.
* No copyright is claimed in the United States under Title 17, U.S. Code.
* All Rights Reserved.
*/
/* @file gmsec_void.h
* This file provides a template for implementing a middleware wrapper.
*/
#ifndef _gmsec_void_h_
#define _gmsec_void_h_
#ifdef WIN32
#ifdef GMSEC_VOID_EXPORTS
#define GMSEC_VOID_API __declspec(dllexport)
#else
#define GMSEC_VOID_API __declspec(dllimport)
#endif
/* disable invalid STL waring for windows targets */
#pragma warning ( disable : 4251 )
#pragma warning ( disable : 4786 )
#else // All other platforms make this macro invisible
#define GMSEC_VOID_API
#endif
#include <gmsec_cpp.h>
#ifdef __cplusplus
extern "C"
{
#endif
/** @fn CreateConnection(Config *cfg, Connection **conn)
* This function wraps the VoidConnection constructor with the standard
* connection creation function prototype.
*
* @sa ConnectionFactory::Create(Config *cfg, Connection *&conn)
*/
GMSEC_VOID_API gmsec::Status
*CreateConnection(gmsec::Config *cfg, gmsec::Connection **conn);
/** @fn DestroyConnection(Connection *conn)
* This function wraps the VoidConnection destructor with the standard
* connection deletion function prototype.
*
* @sa ConnectionFactory::Destroy(Connection *conn)
*/
GMSEC_VOID_API void
DestroyConnection(gmsec::Connection *conn);
#ifdef __cplusplus
} // extern "C"
#endif
#endif /* gmsec_void_h */
/*
* Copyright 2007-2016 United States Government as represented by the
* Administrator of The National Aeronautics and Space Administration.
* No copyright is claimed in the United States under Title 17, U.S. Code.
* All Rights Reserved.
*/
/* @file VoidConnection.cpp
* This file provides a template for implementing a middleware wrapper.
*/
#include <VoidConnection.h>
#include <gmsec/internal/rawbuf.h>
using namespace gmsec;
using namespace gmsec::util;
using namespace std;
VoidConnection::VoidConnection(Config *cfg)
:
BaseConnection(cfg)
{
Status result;
char raw[4000];
rawbuf buffer(raw, sizeof(raw));
ostream os(&buffer);
os << "VoidConnection::VoidConnection:";
if (NULL != cfg)
{
const char * key;
const char * value;
for (result = cfg->GetFirst(key, value);
GMSEC_STATUS_NO_ERROR != result.GetCode();
result = cfg->GetNext(key, value))
{
os << "\n\t(" << key << ',' << value << ')';
}
}
os << ends;
LOG_DEBUG << raw;
}
VoidConnection::~VoidConnection()
{
LOG_DEBUG << "gmsec_void:VoidConnection::~VoidConnection()";
}
const char *VoidConnection::GetLibraryVersion()
{
return "v0.2.1";
}
Status VoidConnection::mwConnect()
{
Status result;
LOG_DEBUG << "gmsec_void:VoidConnection::mwConnect()";
return result;
}
Status VoidConnection::mwDisconnect()
{
Status result;
LOG_DEBUG << "gmsec_void:VoidConnection::mwDisconnect()";
return result;
}
Status VoidConnection::mwSubscribe(const char *subject, const gmsec::Config &config)
{
Status result;
LOG_DEBUG << "gmsec_void:VoidConnection::mwSubscribe(" << subject << ')';
return result;
}
Status VoidConnection::mwUnSubscribe(const char *subject)
{
Status result;
LOG_DEBUG << "gmsec_void:VoidConnection::mwUnSubscribe(" << subject << ')';
return result;
}
Status VoidConnection::mwCreateMessage(const char *subject,
GMSEC_MSG_KIND kind, Message *&msg)
{
Status result;
LOG_DEBUG << "gmsec_void:VoidConnection::mwCreateMessage("
<< (subject ? subject : "[null]")
<< ", kind=" << kind << ", msg=" << msg << ')';
{
VoidMessage * tmp = new VoidMessage();
tmp->SetSubject(subject);
tmp->SetKind(kind);
msg = tmp->createExternal();
}
if (!msg)
{
result.Set(
GMSEC_STATUS_MESSAGE_ERROR,
GMSEC_INVALID_MESSAGE,
"VoidMessage object not created");
LOG_WARNING << result.Get();
}
LOG_DEBUG << "gmsec_void:VoidConnection::mwCreateMessage => " << msg;
return result;
}
#if 0
Status VoidConnection::DestroyMessage(Message *msg)
{
Status result;
LOG_INFO << "gmsec_void:VoidConnection::DestroyMessage(" << msg << ')';
return result;
}
#endif
Status VoidConnection::mwPublish(Message *msg, const gmsec::Config &config)
{
Status result;
LOG_DEBUG << "gmsec_void:VoidConnection::Publish(" << msg << ')';
return result;
}
Status VoidConnection::mwRequest(Message *request, std::string &id)
{
Status result;
LOG_DEBUG << "gmsec_void:VoidConnection::mwRequest(" << request << ')';
return result;
}
Status VoidConnection::mwReply(Message *request, Message *reply)
{
Status result;
LOG_DEBUG << "gmsec_void:VoidConnection::mwReply(request=" << request
<< ", reply=" << reply << ')';
return result;
}
Status VoidConnection::mwGetNextMsg(Message *&msg, GMSEC_I32 timeout)
{
Status result;
LOG_DEBUG << "gmsec_void:VoidConnection::mwGetNextMsg(msg=" << msg
<< ", timeout=" << timeout << ')';
msg = NULL;
result.Set(GMSEC_STATUS_CONNECTION_ERROR,
GMSEC_NO_MESSAGE_AVAILABLE,
"Nothing left.");
return result;
}
// EOF VoidConnection.cpp
/*
* Copyright 2007-2016 United States Government as represented by the
* Administrator of The National Aeronautics and Space Administration.
* No copyright is claimed in the United States under Title 17, U.S. Code.
* All Rights Reserved.
*/
/* @file VoidMessage.cpp
* This file provides a template for implementing a middleware wrapper.
*/
#include <VoidMessage.h>
#include <gmsec/internal/Log.h>
using namespace gmsec;
using namespace gmsec::util;
VoidMessage::VoidMessage()
{
LOG_VERBOSE << "VoidMessage::VoidMessage()";
}
VoidMessage::~VoidMessage()
{
LOG_VERBOSE << "VoidMessage::~VoidMessage()";
}
#ifdef SUBCLASS_BASEMESSAGE
bool VoidMessage::isValid()
{
LOG_VERBOSE << "VoidMessage::isValid()";
return (true);
}
Status VoidMessage::SetKind(GMSEC_MSG_KIND kind)
{
Status result;
LOG_VERBOSE << "VoidMessage::mwSetKind(" << kind << ')';
mType = (size_t) kind;
switch (kind)
{
case GMSEC_MSG_UNSET:
printf("gmsec_void Not Specified\n");
break;
case GMSEC_MSG_PUBLISH:
printf("gmsec_void Proxy - non-blocking\n");
break;
case GMSEC_MSG_REQUEST:
printf("gmsec_void Send()/Receive() - blocking\n");
break;
case GMSEC_MSG_REPLY:
printf("gmsec_void Reply() - non/un-blocking\n");
break;
default:
printf("gmsec_void Error\n");
result.Set(
GMSEC_STATUS_MESSAGE_ERROR,
GMSEC_UNKNOWN_MSG_TYPE,
"Neither Send, Reply, nor Proxy message type");
break;
}
return result;
}
Status VoidMessage::GetKind(GMSEC_MSG_KIND &kind)
{
Status result;
LOG_DEBUG << "VoidMessage::GetKind(" << &kind << ')';
kind = mType;
return result;
}
Status VoidMessage::mwSetSubject(const char *subject)
{
Status result;
LOG_DEBUG << "VoidMessage::mwSetSubject("
(subject ? subject : "[null]") << ')';
return result;
}
Status VoidMessage::GetSubject(const char *&subject)
{
Status result;
LOG_DEBUG << "VoidConnection::GetSubject(" << &subject << ')';
subject = mName;
return result;
}
bool VoidMessage::ProcessConfigValue(const char *name, const char *value)
{
LOG_DEBUG << "VoidConnection::ProcessConfigValue(name="
<< (name ? name : "[null]")
<< ", value=" << (value ? value : "[null]");
return true;
}
Status VoidMessage::ClearFields()
{
Status result;
LOG_DEBUG << "VoidConnection::ClearFields()";
return result;
}
Status VoidMessage::ClearField(const char *name)
{
Status result;
LOG_DEBUG << "VoidConnection::ClearField(name="
<< (name ? name : "[null]") << ')';
return result;
}
Status VoidMessage::GetField(const char *name, Field &field)
{
Status result;
LOG_DEBUG << "VoidConnection::GetField(name="
<< (name ? name : "[null]")
<< ", field=" << &field << ')';
return result;
}
Status VoidMessage::GetFieldCount(GMSEC_I32 &count)
{
Status result;
LOG_DEBUG << "VoidConnection::GetFieldCount(@count=" << &count << ')';
return result;
}
Status VoidMessage::GetFirstField(Field &field)
{
Status result;
LOG_DEBUG << "VoidConnection::GetFirstField(@field=" << &field << ')';
return result;
}
Status VoidMessage::GetNextField(Field &field)
{
Status result;
LOG_DEBUG << "VoidConnection::GetNextField(@field=" << &field << ')';
result.Set(GMSEC_STATUS_MESSAGE_ERROR,
GMSEC_FIELDS_END_REACHED,
"Nominal end-of-fields");
return result;
}
Status VoidMessage::GetMSGSize(unsigned long &size)
{
Status result;
LOG_DEBUG << "VoidConnection::GetMSGSize(@size=" << &size << ')';
return result;
}
#endif /* SUBCLASS_BASEMESSAGE */
// EOF VoidMessage.cpp
/*
* Copyright 2007-2016 United States Government as represented by the
* Administrator of The National Aeronautics and Space Administration.
* No copyright is claimed in the United States under Title 17, U.S. Code.
* All Rights Reserved.
*/
/* @file gmsec_void.h
* This file provides a template for implementing a middleware wrapper.
*/
#include <gmsec_void.h>
#include <gmsec/internal/Log.h>
#include <gmsec/internal/StatusException.h>
#include <VoidConnection.h>
using namespace gmsec;
using namespace gmsec::util;
GMSEC_VOID_API Status *CreateConnection(Config *cfg, Connection **conn)
{
static Status result;
result.ReSet();
LOG_DEBUG << "gmsec_void:CreateConnection(" << cfg << ", " << conn << ")";
try
{
VoidConnection * tmp = new VoidConnection(cfg);
*conn = tmp->createExternal();
}
catch (gmsec::internal::StatusException &se)
{
result = se;
}
LOG_DEBUG << "gmsec_void: *conn=" << *conn;
return &result;
}
GMSEC_VOID_API void DestroyConnection(Connection *conn)
{
LOG_DEBUG << "gmsec_void:DestroyConnection(" << conn << ')';
if (conn)
gmsec::internal::ConnectionBuddy::destroy(conn);
}
// EOF gmsec_void.cpp
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment