Skip to content

Commit

Permalink
header: move ReplyAddress implementation out of the public interface
Browse files Browse the repository at this point in the history
the ReplyAddress struct should be opaque and it really should not be in
the public interface.

Signed-off-by: Tim Blechmann <tim@klingt.org>
  • Loading branch information
timblechmann committed Jul 8, 2013
1 parent a24f843 commit bf8d6fd
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 29 deletions.
1 change: 1 addition & 0 deletions common/SC_Reply.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
*/

#include "SC_Reply.h"
#include "SC_ReplyImpl.hpp"

void null_reply_func(struct ReplyAddress *addr, char* msg, int size)
{}
Expand Down
51 changes: 51 additions & 0 deletions common/SC_ReplyImpl.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
SuperCollider real time audio synthesis system
Copyright (c) 2002 James McCartney. All rights reserved.
Copyright (c) 2013 Tim Blechmann.
http://www.audiosynth.com
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/

#ifndef SC_REPLYIMPL_HPP
#define SC_REPLYIMPL_HPP

#include "SC_Reply.h"

#if defined(_WIN32)
# include "SC_Win32Utils.h"
#else
# include <netinet/in.h>
#endif // _WIN32

struct ReplyAddress
{
struct sockaddr_in mSockAddr;
int mSockAddrLen;
int mSocket;
ReplyFunc mReplyFunc;
void *mReplyData;
};

void null_reply_func(struct ReplyAddress* addr, char* msg, int size);

bool operator==(const ReplyAddress& a, const ReplyAddress& b);

inline void SendReply(struct ReplyAddress *inReplyAddr, char* inBuf, int inSize)
{
(inReplyAddr->mReplyFunc)(inReplyAddr, inBuf, inSize);
}

#endif // SC_REPLYIMPL_HPP
27 changes: 0 additions & 27 deletions include/common/SC_Reply.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,34 +22,7 @@
#ifndef _SC_Reply_
#define _SC_Reply_

#if defined(_WIN32)
# include "SC_Win32Utils.h"
#else
# include <netinet/in.h>
#endif // _WIN32

struct ReplyAddress;

typedef void (*ReplyFunc)(struct ReplyAddress *inReplyAddr, char* inBuf, int inSize);

void null_reply_func(struct ReplyAddress* addr, char* msg, int size);

struct ReplyAddress
{
struct sockaddr_in mSockAddr;
int mSockAddrLen;
int mSocket;
ReplyFunc mReplyFunc;
void *mReplyData;
};

#if defined(__cplusplus)
bool operator==(const ReplyAddress& a, const ReplyAddress& b);
#endif // __cplusplus

inline void SendReply(struct ReplyAddress *inReplyAddr, char* inBuf, int inSize)
{
(inReplyAddr->mReplyFunc)(inReplyAddr, inBuf, inSize);
}

#endif
2 changes: 1 addition & 1 deletion lang/LangPrimSource/SC_Msg.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include <stdio.h>
#include <stdlib.h>

#include "SC_Reply.h"
#include "SC_ReplyImpl.hpp"
#include "sc_msg_iter.h"

class SC_Msg;
Expand Down
2 changes: 1 addition & 1 deletion server/scsynth/OSC_Packet.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#ifndef _OSC_Packet_
#define _OSC_Packet_

#include "SC_Reply.h"
#include "SC_ReplyImpl.hpp"
#include "SC_Types.h"

struct OSC_Packet
Expand Down

0 comments on commit bf8d6fd

Please sign in to comment.